3 ms·
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 ab
by scott_s 17y ago
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.
- skwiddor 17y agothere are other models http://plan9.bell-labs.com/magic/man2html/2/thread http://plan9.bell-labs.com/magic/man2html/2/thread