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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
From: Christian Kastner <ckk@kvr.at>
Date: Tue, 22 Dec 2015 20:05:42 +0100
Subject: Redirect daemon standard streams to /dev/null
Redirect the daemon's stdin/stdout/stderr from resp. to /dev/null.
Fixes provided by Steve Greenland <stevegr@debian.org>.
Debian-Bug: https://bugs.debian.org/23231
Debian-Bug: https://bugs.debian.org/30653
Debian-Bug: https://bugs.debian.org/37189
Forwarded: no
Last-Update: 2015-12-22
---
cron.c | 5 +++++
do_command.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/cron.c b/cron.c
index c424c77..1db8569 100644
--- a/cron.c
+++ b/cron.c
@@ -31,6 +31,8 @@ static char rcsid[] = "$Id: cron.c,v 2.11 1994/01/15 20:43:43 vixie Exp $";
# include <time.h>
#endif
+#include <sys/types.h>
+#include <fcntl.h>
static void usage __P((void)),
run_reboot_jobs __P((cron_db *)),
@@ -104,6 +106,9 @@ main(argc, argv)
/* child process */
log_it("CRON",getpid(),"STARTUP","fork ok");
(void) setsid();
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
break;
default:
/* parent process should just die */
diff --git a/do_command.c b/do_command.c
index f596252..f18f670 100644
--- a/do_command.c
+++ b/do_command.c
@@ -191,6 +191,7 @@ child_process(e, u)
dup2(stdout_pipe[WRITE_PIPE], STDOUT);
dup2(STDOUT, STDERR);
+
/* close the pipes we just dup'ed. The resources will remain.
*/
close(stdin_pipe[READ_PIPE]);
|