__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.
__acquire_ptc();
pid = __vfork();
- __release_ptc();
if (pid) {
+ __release_ptc();
sigprocmask(SIG_SETMASK, &oldmask, 0);
if (pid < 0) return -pid;
*res = pid;
__acquire_ptc();
pid = __vfork();
- __release_ptc();
+
+ if (pid) __release_ptc();
if (pid > 0) {
sigset_t new = old;
__acquire_ptc();
pid = __vfork();
- __release_ptc();
if (pid) {
+ __release_ptc();
__syscall(SYS_close, p[1-op]);
sigprocmask(SIG_BLOCK, SIGALL_SET, &old);
if (pid < 0) {