[PATCH 2/2] start-stop-daemon - find processes better

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Thu May 1 11:39:16 UTC 2008


> -----Original Message-----
> From: Roy Marples [mailto:roy at marples.name]
> Sent: den 30 april 2008 18:19
> To: joakim.tjernlund at transmode.se
> Cc: Denys Vlasenko; busybox at busybox.net
> Subject: Re: [PATCH 2/2] start-stop-daemon - find processes better
> 
> On Wednesday 30 April 2008 16:25:10 Joakim Tjernlund wrote:
> > > But the intent of start-stop-daemon is to start and stop daemons.
> > > s-s-d --stop --exec /usr/sbin/ntpd
> > > I would that expect it to stop the currently running ntpd process
> > > regardless of if the binary itself still exists or not.
> >
> > Don't think so, this is what --name is for. At least I think so.
> 
> --name is for checking the process name, or argv[0], which is different from
> how the daemon is started.
> 
> >
> > > > > It
> > > > > wont work when cmdline i a symlink. Should you not use --name instead
> > > > > to handle the deleted case?
> > >
> > > But this is good :)
> > > Consider busybox - loads of things symlink into it, like udhcpd. So are
> > > you stopping udhcpd or all instances of busybox daemons?
> >
> > You won't stop anything with your solution because /proc/xxx/exe
> > contains the real file name. So
> >   s-s-d --stop --exec /bin/mysymlinkeddaemon
> > will not match.
> 
> Good point.
> New patch attached which just checks cmdline instead of doing exe then
> cmdline.
> 
> function                                             old     new   delta
> start_stop_daemon_main                               984    1006     +22
> .rodata                                           119312  119303      -9
> check                                                755     714     -41
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 1/2 up/down: 22/-50)            Total: -28 bytes
> 
> So that's now an overall code shrink :)
> 
> Also you should consider the case of scripts. If /usr/bin/foo is  a python
> script, and was started like
> start-stop-daemon --start --exec /usr/bin/foo
> then you could reasonably expect
> start-stop-daemon --stop --exec /usr/bin/foo
> to work. However it won't because the exe inode points at python and not the
> script.

Roy, the above all makes sense and your patch looks good too. One minor
thing, I don't think you need the 
+	if (execname)
+		xstat(execname, &execstat);
anymore or am I missing something?

 Jocke




More information about the busybox mailing list