소스 검색

s-s-d: Move setsid() alternative code into a replacement setsid() function

Guillem Jover 14 년 전
부모
커밋
1ea1205bd4
1개의 변경된 파일과 9개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 5
      utils/start-stop-daemon.c

+ 9 - 5
utils/start-stop-daemon.c

@@ -340,6 +340,15 @@ detach_controlling_tty(void)
 	close(tty_fd);
 	close(tty_fd);
 #endif
 #endif
 }
 }
+
+static pid_t
+setsid(void)
+{
+	setpgid(0, 0);
+	detach_controlling_tty();
+
+	return 0;
+}
 #endif
 #endif
 
 
 static void
 static void
@@ -357,12 +366,7 @@ daemonize(void)
 		_exit(0);
 		_exit(0);
 
 
 	/* Create a new session. */
 	/* Create a new session. */
-#ifdef HAVE_SETSID
 	setsid();
 	setsid();
-#else
-	setpgid(0, 0);
-	detach_controlling_tty();
-#endif
 
 
 	pid = fork();
 	pid = fork();
 	if (pid < 0)
 	if (pid < 0)