On Fri, 20 Oct 2017 16:25:32 +0200, Florian Riehm wrote:
> cron(8) opens /var/run/cron.sock for communication with crontab(1).
> The forked cronjobs have the socked still open.
> This prevents restarting cron while a job is running:
> (CRON) DEATH (already running)
>
> I think cron's children should not inherit sockets.
There is a similar issue with at jobs. Here's a comprehensive diff.
- todd
Index: usr.sbin/cron/atrun.c
===================================================================
RCS file: /cvs/src/usr.sbin/cron/atrun.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 atrun.c
--- usr.sbin/cron/atrun.c 8 Jun 2017 16:23:39 -0000 1.46
+++ usr.sbin/cron/atrun.c 20 Oct 2017 15:09:57 -0000
@@ -283,6 +283,9 @@ run_job(const atjob *job, int dfd, const
return;
}
+ /* close fds opened by the parent (e.g. cronSock) */
+ closefrom(3);
+
/*
* We don't want the main cron daemon to wait for our children--
* we will do it ourselves via waitpid().
Index: usr.sbin/cron/do_command.c
===================================================================
RCS file: /cvs/src/usr.sbin/cron/do_command.c,v
retrieving revision 1.56
diff -u -p -u -r1.56 do_command.c
--- usr.sbin/cron/do_command.c 17 Nov 2015 22:31:44 -0000 1.56
+++ usr.sbin/cron/do_command.c 20 Oct 2017 15:10:03 -0000
@@ -86,6 +86,9 @@ child_process(entry *e, user *u)
/* mark ourselves as different to PS command watchers */
setproctitle("running job");
+ /* close fds opened by the parent (e.g. cronSock) */
+ closefrom(3);
+
/* discover some useful and important environment settings
*/
usernm = e->pwd->pw_name;