瀏覽代碼

Merge trunk revision 2948:
r2948 | beekhof | 2010-06-18 07:33:01 -0700 (Fri, 18 Jun 2010) | 6 lines

Prevent segfault in fork()

Not closing stdin/stderr/stdout leads to a segfault in fresetlockfiles()
See https://lists.linux-foundation.org/pipermail/openais/2010-June/014854.html for further info.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2951 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 15 年之前
父節點
當前提交
b164a5435f
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      exec/main.c

+ 3 - 0
exec/main.c

@@ -418,6 +418,9 @@ static void corosync_tty_detach (void)
 	fd = open("/dev/null", O_RDWR);
 	if (fd >= 0) {
 		/* dup2 to 0 / 1 / 2 (stdin / stdout / stderr) */
+		close (STDIN_FILENO);
+		close (STDOUT_FILENO);
+		close (STDERR_FILENO);
 		dup2(fd, STDIN_FILENO);  /* 0 */
 		dup2(fd, STDOUT_FILENO); /* 1 */
 		dup2(fd, STDERR_FILENO); /* 2 */