diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-10-19 15:02:37 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-10-19 15:02:37 -0400 |
commit | 599f97360389911c293e0ca4c5eb49e007377fba (patch) | |
tree | 9df3f1e50357956c4cc76cd8e2872f342c80bf3c /src/process/system.c | |
parent | ebee8c2b477807fe58fd35d35783633ea08b049c (diff) | |
download | musl-599f97360389911c293e0ca4c5eb49e007377fba.tar.gz |
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.
Diffstat (limited to 'src/process/system.c')
-rw-r--r-- | src/process/system.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/process/system.c b/src/process/system.c index c8f26008..ebe207f5 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -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; |