From 599f97360389911c293e0ca4c5eb49e007377fba Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 19 Oct 2012 15:02:37 -0400 Subject: 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. --- src/stdio/popen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/stdio') diff --git a/src/stdio/popen.c b/src/stdio/popen.c index 0c9f24e3..5a47509e 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -38,9 +38,9 @@ FILE *popen(const char *cmd, const char *mode) __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) { -- cgit v1.2.1