fix usage of locks with vfork
[musl] / src / stdio / popen.c
index 0c9f24e..5a47509 100644 (file)
@@ -38,9 +38,9 @@ FILE *popen(const char *cmd, const char *mode)
        
        __acquire_ptc();
        pid = __vfork();
        
        __acquire_ptc();
        pid = __vfork();
-       __release_ptc();
 
        if (pid) {
 
        if (pid) {
+               __release_ptc();
                __syscall(SYS_close, p[1-op]);
                sigprocmask(SIG_BLOCK, SIGALL_SET, &old);
                if (pid < 0) {
                __syscall(SYS_close, p[1-op]);
                sigprocmask(SIG_BLOCK, SIGALL_SET, &old);
                if (pid < 0) {