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
Index: cron/cron.c
===================================================================
--- cron.orig/cron.c
+++ cron/cron.c
@@ -31,6 +31,8 @@ static char rcsid[] = "$Id: cron.c,v 2.1
 # 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 */
Index: cron/do_command.c
===================================================================
--- cron.orig/do_command.c
+++ cron/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]);
