pending patches

Denys Vlasenko vda.linux at googlemail.com
Fri Nov 7 10:04:56 UTC 2008


On Friday 07 November 2008 08:04, Vladimir Dronnikov wrote:
> http://drvv.ru/busybox/acpid.patch
> >
> > +       argv += optind;
> > +       // daemonize unless -d given
> > +       if (!(option_mask32 & 1)) { // ! -d
> > +               forkexit_or_rexec(argv);
> >
> > (1) argv is wrong here, you did argv += optind too early.
> 
> Right.
> 
> (2) forkexit_or_rexec() in general is an internal function.
> >     Use bb_daemonize_or_rexec() instead, it does this and
> >     also all of the below...
> >
> > +               setsid();
> > +               // close 0, 1?
> > +               // ?
> > +               // reopen stderr
> > +               freopen(opt_logfile, "w", stderr);
> > +       }
> 
> I don't want /dev/null to be my stderr. bb_daemonize_or_rexec() would do
> unnecessary things here.

Yes, extra close and dup2. Two microseconds wasted per each acpid startup.
Horror. ;)

> but more importantly, why daemonizing at all? This works:
> > setsid acpid ... </dev/null >/dev/null 2>somewhere &
> 
> We daemonize in inetd et.al. only because that is
> > their historical behavior... is daemonization something
> > you need for compat reasons?
> 
> Personally, I use acpid as runit service. Daemonizing was requested as it is
> "default behaviour of big brother".

Then it's ok.

> +               while (!bb_got_signal && safe_poll(pfd, nfd, -1) > 0) {
> >
> > safe_poll() will loop on EINTR. Thus SIGINT will not interrupt it,
> > it may sit like this forever.
> 
> It is intended to be SIGTERMed to exit. As other services do.

Yes, in the code above SIGTERM will not kill it either.
It will exit only after poll() will see some input,
and THEN program will notice what SIGTERM was received.

--
vda



More information about the busybox mailing list