syslog function: Bad file descriptor
Wed Aug 6 09:19:00 GMT 2014
On Aug 5 22:35, D. Boland wrote:
> Corinna Vinschen wrote:
> > Can you produce another strace for the overwriting case (non-R/O aliases)
> > for comparison? Also, can you do the same strace with no syslogd running?
> > It might be necessary to create a few test versions of Cygwin with more
> > debug output, but let's please see these straces first.
> I attached all three of them in a zipped file.
Thanks. I got it now. AFAICS it's a bug in sendmail. Take a look
into your newaliases.strace.txt file. Start at line 260 (stripping
off timestamp, thread and process info):
260: normalize_posix_path: src /dev/log
Here the syslog() function tries to open a connection to a syslogd
listening on /dev/log.
282: cygwin_socket: 3 = socket(1, 2 (flags 0x0), 0)
Socket created, file descriptor is 3.
296: connect_syslogd: found /dev/log, fd = 3, type = DGRAM
Yes, there's a listener on /dev/log. Now Cygwin stores the info that fd
3 is the connection to the syslog daemon.
332: close: close(3)
And at line 332, a file descriptor close orgy starts. sendmail closes
all descriptors from 3 to 255. This obviously closes fd 3, but how's
Cygwin's syslog() function to know?
2263: open: 3 = open(/etc/mail/aliases, 0x8000)
Uh oh! Now fd 3 is reused for the aliases file. Things certainly go
2651: writev: -1 = writev(3, 0x2287F0, 2), errno 9
This is syslog trying to write the log to the descriptor it knows
is connected to /dev/log. Fortunately the aliases file is R/O at
this point, but it's pretty much working as designed. Syslog()
doesn't know the application broke its connection to the syslog
daemon. It dutyfully writes to the syslog descriptor it knows
As for using a file descriptor inside of syslog, that's perfectly
valid behaviour, see
"The openlog() and syslog() functions may allocate a file descriptor."
Without looking into the sources, I'd assume there's a closelog()
call missing prior to the descriptor close orgy. This closelog()
call should fix the problem.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: not available
More information about the Cygwin