syslog access violation

Robert Collins robert.collins@itdomain.com.au
Thu Jul 13 18:27:00 GMT 2000


Hi everyone,
    I posted a week or so about a problem with daemon (squid), when it
closed fd(2). I've tracked that down a bit more as there were remaining
problems, and found that fd(1) and fd(2) can't be closed by the daemon or
syslog dies, either that or something called by syslog. I haven't got gdb
attaching to the daemon properly yet so I have been // code lines.. arghh...

The question is:
Looking through syslog.cc, debug_printf is used quite a bit. Does this write
to fd 1 or 2?
Call me silly but I can't find the code for debug_printf to check myself...

I wrote a test package that does a similar call sequence to the daemon, but
it doesn't stackdump or access violate, so I assume it must be a combination
of other activies undertaken by the child process...



#include <stdio.h>
#include <sys/syslog.h>

int main (int argc, char **argv)
{
int i;
int pid,status;

   openlog("testparent", LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
   if ((pid = fork()) < 0)
       syslog(LOG_ALERT, "fork failed: %m");
   else if (pid > 0)
       exit(0);

closelog();
for(i=0;i<8192;i++)
close(i);
if ((pid=fork()) == 0){
openlog("test",LOG_PID|LOG_NDELAY|LOG_CONS, LOG_LOCAL4);
syslog(LOG_ALERT,"syslog call from test");
}
openlog("test",LOG_PID|LOG_NDELAY|LOG_CONS, LOG_LOCAL4);
syslog(LOG_ALERT,"syslog call from test");
pid=waitpid(-1,&status,0);
syslog(LOG_ALERT,"syslog call from test");

return 0;
}



More information about the Cygwin-apps mailing list