[BusyBox] Re: syslogd sometimes dies writing to remote logger
Dan Kegel
dank at kegel.com
Tue Apr 2 12:07:04 UTC 2002
Larry Doolittle wrote:
>
> > BTW, looking through the code, I noticed that the MARK message is
> > written from inside a signal handler. I think, but can't be sure, the
> > crash happened at the time a MARK was expected. I've restarted syslogd
> > without MARK writing to see what happens.
> > Is the code kosher? I was taught way back in the early days of Unix that
> > one should not do anything more in a signal handler than setting a flag.
>
> That's old-style paranoia. The SUS2 sigaction page
> http://www.opengroup.org/onlinepubs/007908799/xsh/sigaction.html
> lists 76 base functions that are permitted inside signal handlers.
> write() is on the list.
There's a grain of truth to it, though. That same page cautions us
"Note in particular that even the "safe" functions may modify errno; the
signal-catching function, if not executing as an independent thread,
may want to save and restore its value."
I can imagine a nasty race condition where the 'wrong' value of
errno sneaks in.
If you follow the old-style paranoia, and don't call any function
that can set errno, you're safe from this particular rare race condition
BTW, the SUS3 sigaction page is at
http://www.opengroup.org/onlinepubs/007904975/functions/sigaction.html
but I think you have to register to look at it.
- Dan
More information about the busybox
mailing list