'kill 0' from cron script kills crond

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Wed Dec 3 08:24:35 UTC 2008


On Tue, Dec 02, 2008 at 10:49:34PM +0100, Denys Vlasenko wrote:
>On Tuesday 02 December 2008 17:40, Jeroen van der Vegt wrote:
>> Hello, 
>> 
>> 
>> We're using Busybox on an embedded ARM platform. We'd like to have a script
>> running from cron every minute. To terminate any remaining child processes,
>> we'd like to perform the 'kill 0' command at the end of the script. This '0'
>> is a special argument. From e.g.
>> http://linux.about.com/od/commands/l/blcmdl1_kill.htm :
>> 
>> ..... 
>> 0
>>     All processes in the current process group are signalled. 
>> .... 
>> 
>> It seems that this command works in Busybox as well. However, if we use this
>> in a script that is run from 'crond', crond itself is killed as well. That
>> is obviously not as expected, and indeed different from the behaviour of a
>> system without Busybox.
>
>This means that "standard" cron puts each child into new process group.
>(BTW, this "standard" crond - what --version and/or --help says?)
>
>Please try this patch, does it fix the problem?

please use bb_setpgrp (see platform.h).
>--
>vda
>

>--- busybox.5/miscutils/crond.c	Thu Nov  6 01:49:19 2008
>+++ busybox.t5/miscutils/crond.c	Tue Dec  2 22:47:20 2008
>@@ -779,6 +779,8 @@
> 			xmove_fd(mailFd, mail_filename ? 1 : 0);
> 			dup2(1, 2);
> 		}
>+		/* "standard" cron puts tasks in separate process groups */
>+		setpgrp();
> 		execlp(prog, prog, cmd, arg, NULL);
> 		crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg);
> 		if (mail_filename) {
>@@ -914,6 +916,8 @@
> 		if (DebugOpt) {
> 			crondlog(LVL5 "child running %s", DEFAULT_SHELL);
> 		}
>+		/* "standard" cron puts tasks in separate process groups */
>+		setpgrp();
> 		execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
> 		crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
> 				 DEFAULT_SHELL, "-c", line->cl_Shell);

>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox



More information about the busybox mailing list