7.5.2.7: Library Functions Used Between fork() and exec()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ah, multi-threaded fork, my arch-nemesis.

A few points, though I'm not sure any of these are worth mentioning in the book:

1. It should perhaps be made clear that the child's copy of the lock
is, in fact, a separate lock. The statement that the lock is held by a
parent thread is somewhat inaccurate. That is, unless the lock is in
explicitly-shared memory (i.e., the result of mmap(MAP_SHARED)), in
which case the lock is indeed the same and is (presumably) meant to be
shared between the parent and child.

2. POSIX explicitly says that you can't execute any
non-async-signal-safe functions between fork() and exec(), which
pretty much eliminates any function that acquires a lock.

3. posix_spawn() is a safer alternative to the fork()/exec() pair
(though not to fork() by itself), at least with sensible
implementations that don't devolve to fork() and exec().

--Elad



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux