소스 검색

remove spurious lock in popen

the newly allocated FILE * has not yet leaked to the application and
is only visible to stdio internals until popen returns. since we do
not change any fields of the structure observed by libc internals,
only the pipe_pid member, locking is not necessary.
Rich Felker 3 년 전
부모
커밋
e74acd59a5
1개의 변경된 파일0개의 추가작업 그리고 2개의 파일을 삭제
  1. 0 2
      src/stdio/popen.c

+ 0 - 2
src/stdio/popen.c

@@ -31,7 +31,6 @@ FILE *popen(const char *cmd, const char *mode)
 		__syscall(SYS_close, p[1]);
 		return NULL;
 	}
-	FLOCK(f);
 
 	e = ENOMEM;
 	if (!posix_spawn_file_actions_init(&fa)) {
@@ -43,7 +42,6 @@ FILE *popen(const char *cmd, const char *mode)
 				if (!strchr(mode, 'e'))
 					fcntl(p[op], F_SETFD, 0);
 				__syscall(SYS_close, p[1-op]);
-				FUNLOCK(f);
 				return f;
 			}
 		}