Răsfoiți Sursa

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/trunk@2948 fd59a12c-fef9-0310-b244-a6a79926bd2f
Andrew Beekhof 15 ani în urmă
părinte
comite
daa85f8f6c
1 a modificat fișierele cu 3 adăugiri și 0 ștergeri
  1. 3 0
      exec/main.c

+ 3 - 0
exec/main.c

@@ -495,6 +495,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 */