Re:Everything is Unix
by scott_s on Monday October 12, 2009 @05:08PM
(#877652)
You shouldn't have to call fork() yourself. Most languages have either language level or library level solutions that abstract that away for you. You want to abstract it away because very soon you'll find yourself wanting to manage the forked processes in much the same way these other facilities do it for you. Even when I'm working in C, I almost always use Pthreads instead of calling fork() directly. The only time I call fork() is when it's soon followed by an execve().
The same goes for file locking. Using files for synchronization is primitive, error prone and slow. As soon as you find yourself managing the lock files to deal with crashed programs ("stale locks" as the author calls them), you might as well trade it in for better abstractions.
Perhaps the most valuable part of implementing this kind of stuff by hand, using only systems services, is the appreciation you gain from having access to the same functionality in your language or from well designed libraries.
The same goes for file locking. Using files for synchronization is primitive, error prone and slow. As soon as you find yourself managing the lock files to deal with crashed programs ("stale locks" as the author calls them), you might as well trade it in for better abstractions.
Perhaps the most valuable part of implementing this kind of stuff by hand, using only systems services, is the appreciation you gain from having access to the same functionality in your language or from well designed libraries.