SHA256
1
0
forked from pool/gpm
gpm/gpm-1.20.1-daemon_mode.patch

29 lines
1.2 KiB
Diff

--- src/headers/message.h
+++ src/headers/message.h
@@ -145,6 +145,7 @@
#define GPM_MESS_SETSID_FAILED "Setsid failed"
#define GPM_MESS_CHDIR_FAILED "change directory failed"
#define GPM_MESS_FORK_FAILED "Fork failed."
+#define GPM_MESS_DAEMON_FAILED "Change to run in background failed."
#define GPM_MESS_VCCHECK "Failed on virtual console check."
#define GPM_MESS_PROT_ERR "Error in protocol"
#define GPM_MESS_ROOT "You should be root to run gpm!"
--- src/startup.c
+++ src/startup.c
@@ -136,13 +136,8 @@
if(option.run_status == GPM_RUN_STARTUP ) { /* else is debugging */
/* goto background and become a session leader (Stefan Giessler) */
- switch(fork()) {
- case -1: gpm_report(GPM_PR_OOPS,GPM_MESS_FORK_FAILED); /* error */
- case 0: option.run_status = GPM_RUN_DAEMON; break; /* child */
- default: _exit(0); /* parent */
- }
-
- if (setsid() < 0) gpm_report(GPM_PR_OOPS,GPM_MESS_SETSID_FAILED);
+ if (daemon(0,0)) gpm_report(GPM_PR_OOPS,GPM_MESS_DAEMON_FAILED); /* error */
+ option.run_status = GPM_RUN_DAEMON;
}
/* damon init: check whether we run or not, display message */