projects
/
NeonServV5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a0f5e33
)
redirect stdin/stdout/stderr to /dev/null after forking into background && close...
author
pk910
<philipp@zoelle1.de>
Sun, 5 Feb 2012 12:11:00 +0000
(13:11 +0100)
committer
pk910
<philipp@zoelle1.de>
Sun, 5 Feb 2012 12:12:15 +0000
(13:12 +0100)
src/main.c
patch
|
blob
|
history
diff --git
a/src/main.c
b/src/main.c
index dc76d7a661043e0fe36f98114a7a8744268f92f2..fb8abcebbf7e51aace68d7d0950f9a2fcc860c07 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-149,6
+149,10
@@
void exit_daemon() {
if(daemonized) {
remove(PID_FILE);
}
if(daemonized) {
remove(PID_FILE);
}
+ if(log_fptr) {
+ fclose(log_fptr);
+ log_fptr = NULL;
+ }
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
@@
-194,6
+198,7
@@
int main(int argc, char *argv[]) {
}
check_firstrun();
if (run_as_daemon) {
}
check_firstrun();
if (run_as_daemon) {
+ #ifndef WIN32
/* Attempt to fork into the background if daemon mode is on. */
pid_t pid = fork();
if (pid < 0) {
/* Attempt to fork into the background if daemon mode is on. */
pid_t pid = fork();
if (pid < 0) {
@@
-214,9
+219,10
@@
int main(int argc, char *argv[]) {
fprintf(pidfile, "%i\n", (int)getpid());
fclose(pidfile);
}
fprintf(pidfile, "%i\n", (int)getpid());
fclose(pidfile);
}
- fclose(stdin);
- fclose(stdout);
- fclose(stderr);
+ fclose(stdin); fopen("/dev/null", "r");
+ fclose(stdout); fopen("/dev/null", "w");
+ fclose(stderr); fopen("/dev/null", "w");
+ #endif
}
main:
}
main: