Browse Source

daemonize: check setsid() return value

Maxim Zakharov 10 years ago
parent
commit
833549edba
1 changed files with 2 additions and 1 deletions
  1. 2 1
      ccan/daemonize/daemonize.c

+ 2 - 1
ccan/daemonize/daemonize.c

@@ -33,7 +33,8 @@ bool daemonize(void)
 	close(0);
 	close(0);
 
 
 	/* Session leader so ^C doesn't whack us. */
 	/* Session leader so ^C doesn't whack us. */
-	setsid();
+	if (setsid() == (pid_t)-1)
+	        return false;
 	/* Move off any mount points we might be in. */
 	/* Move off any mount points we might be in. */
 	if (chdir("/") != 0)
 	if (chdir("/") != 0)
 		return false;
 		return false;