summaryrefslogtreecommitdiff
blob: a365f0c3ce3c18b7b27be1e38aa646bd2ebb8e84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff -urN vixie-cron-3.0.1.orig/cron.c vixie-cron-3.0.1/cron.c
--- vixie-cron-3.0.1.orig/cron.c	2003-11-07 11:33:38.000000000 -0600
+++ vixie-cron-3.0.1/cron.c	2003-11-12 12:37:42.000000000 -0600
@@ -25,6 +25,8 @@
 
 #include "cron.h"
 #include <sys/signal.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #if SYS_TIME_H
 # include <sys/time.h>
 # include <time.h>
@@ -58,6 +60,7 @@
 	char	*argv[];
 {
 	cron_db	database;
+	int i;
 
 	ProgramName = argv[0];
 
@@ -108,6 +111,16 @@
 		}
 	}
 
+	/* close stdin, stdout, and stderr */
+	if ( (i = open("/dev/null", O_RDWR)) < 0) {
+		log_it("CRON",getpid(),"DEATH","can't open /dev/null");
+		exit(0);
+	}
+	close(0); dup2(i, 0);
+	close(1); dup2(i, 1);
+	close(2); dup2(i, 2);
+	close(i);
+
 	acquire_daemonlock(0);
 	database.head = NULL;
 	database.tail = NULL;