ifplugd: the SIGHUP handling and repeated setenv calls

Rob Landley rob at landley.net
Tue Apr 27 04:46:41 UTC 2010


On Wednesday 21 April 2010 04:46:49 Maksym Kryzhanovskyy wrote:
> > > 2. What may happen with repeated setenv() calls?
> > >
> > > if (status != G.iface_last_status) {
> > >        //TODO: is it safe to repeatedly do this?
> > >        setenv(IFPLUGD_ENV_PREVIOUS, strstatus(G.iface_last_status), 1);
> > >        setenv(IFPLUGD_ENV_CURRENT, strstatus(status), 1);
> > >        G.iface_last_status = status;
> > > }
> >
> > There is no guarantee successive setenv's do not allocate
> > new malloc bocks to construct "VAR=VAL" strings without
> > freeing ones from previous calls.
>
> I understand. I looked at the setenv implementation in glibc and uClibc.
> Can we do something with it? Apply xsetenv from libbb there is not probably
> a good idea?

Here's my blog entry from back when I first tried to tackle this issue back 
when I was working on a "bbsh", detailing what you need to do to fix it 
properly:

  http://landley.net/notes-2006.html#24-10-2006

(It really only comes up in command shells.  Other things just don't set 
enough environment variables enough times within a single long-lived process 
to care.)

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds



More information about the busybox mailing list