On Friday 04 September 2009 19:09, Doug Graham wrote:
> Cathey, Jim wrote:
> > I didn't think vforked children shared fd's, only memory maps.
> > So correct me if I'm wrong, but the problem is that the
> > child side changed a global, not that it closed the file.
> > So why not just close the file descriptor on the child side
> > _without_ changing any globals, like state variables or
> > buffered I/O streams? Then it'd be safe even if it _was_
> > missing FD_CLOEXEC.
> >
> This isn't just an academic question. uClibc 0.9.30 doesn't set FD_CLOEXEC
> on the logging descriptor.
It does. uClibc-0.9.30/libc/misc/syslog/syslog.c
void
openlog(const char *ident, int logstat, int logfac)
{
int logType = SOCK_DGRAM;
__UCLIBC_MUTEX_LOCK(mylock);
if (ident != NULL)
LogTag = ident;
LogStat = logstat;
if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
LogFacility = logfac;
if (LogFile == -1) {
retry:
if (LogStat & LOG_NDELAY) {
if ((LogFile = socket(AF_UNIX, logType, 0)) == -1) {
goto DONE;
}
HERE ====> fcntl(LogFile, F_SETFD, 1); /* 1 == FD_CLOEXEC */
/* We don't want to block if e.g. syslogd is SIGSTOPed
*/
fcntl(LogFile, F_SETFL, O_NONBLOCK | fcntl(LogFile,
F_GETFL));
}
}
...
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox