fix usage of locks with vfork

__release_ptc() is only valid in the parent; if it's performed in the
child, the lock will be unlocked early then double-unlocked later,
corrupting the lock state.
This commit is contained in:
Rich Felker 2012-10-19 15:02:37 -04:00
commit 599f973603
3 changed files with 4 additions and 3 deletions

View file

@ -35,9 +35,9 @@ int __posix_spawnx(pid_t *restrict res, const char *restrict path,
__acquire_ptc();
pid = __vfork();
__release_ptc();
if (pid) {
__release_ptc();
sigprocmask(SIG_SETMASK, &oldmask, 0);
if (pid < 0) return -pid;
*res = pid;

View file

@ -29,7 +29,8 @@ int system(const char *cmd)
__acquire_ptc();
pid = __vfork();
__release_ptc();
if (pid) __release_ptc();
if (pid > 0) {
sigset_t new = old;