Can I rely absolutely on what happens when a process dies.

David Collier from_busybox_maillist at dexdyne.com
Tue Dec 7 17:40:00 UTC 2010


In article <AANLkTinaOrz_brur-S2zngkW4MEoZCrkE=__3KgJrOs_ at mail.gmail.com>,
vda.linux at googlemail.com (Denys Vlasenko) wrote:

> *From:* Denys Vlasenko <vda.linux at googlemail.com>
> *To:* from_busybox_maillist at dexdyne.com
> *CC:* busybox at busybox.net, jered at dexdyne.com
> *Date:* Tue, 7 Dec 2010 12:04:15 +0100
> 
> On Tue, Dec 7, 2010 at 11:26 AM, David Collier
> <from_busybox_maillist at dexdyne.com> wrote:
> > I am struggling a bit with locating and sending signals to 
> > processes like
> > udhcpc.
> >
> > I enabled the "write your pid to this file" option... but of 
> > course the
> > file persists after the process dies... so if you look in the 
> > file for a
> > pid... and some other process has started up in the meantime with 
> > the
> > SAME pid, you will send your signal to the wrong flipping process.
> >
> > IN THE SHORT TERM.... my way around this could be to write a 
> > small script
> > such as
> >
> >   # -f means "don't fork"
> >   udchpc ......... -f -pidfile /tmp/fred
> >   # we will only get here when udhcpc has ended
> >   rm /tmp/fred
> >
> > My question is - can I rely completely on the principle that no 
> > matter
> > how udhcpc comes to an end ( exit, seg fault, OOM handling 
> > whatever ) the
> > script will be resumed ( provided OOM hasn't got to it ) , and 
> > the rm
> > command executed?
> 
> Unless the shell which executes the script is killed.
> While udchpc runs, shell (it's parent process which executes the 
> script)
> waits for udchpc to terminate. It (shell) can be killed.
> This doesn't affect udhcpc, but anything after it in the script 
> won't run.
> 
> Pid files are not very robust in general.

so I'm beginning to understand.

I have spent the day sorting out a script function which searches ps for
a particular pid at the start of the line, and a particular "executable
name" at the end of the line - if I find that I declare the process still
running, and allow myself to signal it. Particularly with SIGKILL!!

A lot of the issues I'm seeing will only occur during debugging, when I'm
starting and stopping processes madly, and often with -9
But I still feel the need to fix them if I see them!

> What are you trying to achieve on a bigger scale?
> (I mean, using the pid from pidfile is an element of some
> bigger plan of yours. What is it?)

thanks

I'll take my chances on the shell going away - I can't have a perfect
world.
( there is a h/w watchdog about which might pick that up )

what I'm about is as described in

*From:* "David Collier" <from_busybox_maillist at dexdyne.com>
*To:* busybox at busybox.net
*Date:* Mon, 6 Dec 2010 11:09 +0000 (GMT Standard Time)

I have seen your reply suggesting runsv - and I will think about going
that way, but in the meantime I need my existing knife-and-fork scripting
to sort-of-work.

TVM

D



More information about the busybox mailing list