#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
pid_t child = 0;
int status = 0;
FILE *fp;
- int nullfd;
+// int nullfd;
--argc;
++argv;
* We don't just call close() because we don't want these fd's
* to be reused for other files.
*/
+/*
nullfd = open("/dev/null", O_RDWR);
if (nullfd < 0) {
fprintf(stderr, "/dev/null: %s\n", strerror(errno));
dup2(nullfd, 1);
dup2(nullfd, 2);
close(nullfd);
-
+*/
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
}
exit(0);
}
+
+ setsid();
+ chdir("/");
+ umask(0);
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
do {
current_child = fork();