diff --git a/minilogd.c b/minilogd.c index b24fb75..1687f62 100644 --- a/minilogd.c +++ b/minilogd.c @@ -153,9 +153,11 @@ int main(int argc, char **argv) { if (argc>1) debug=1; /* just in case */ sock = open("/dev/null",O_RDWR); - dup2(sock,0); - dup2(sock,1); - dup2(sock,2); + + int dupret=0; + dupret=dup2(sock,0); + dupret=dup2(sock,1); + dupret=dup2(sock,2); bzero(&addr, sizeof(addr)); addr.sun_family = AF_LOCAL; @@ -163,7 +165,11 @@ int main(int argc, char **argv) { sock = socket(AF_LOCAL, SOCK_STREAM,0); unlink(_PATH_LOG); /* Bind socket before forking, so we know if the server started */ - if (!bind(sock,(struct sockaddr *) &addr, sizeof(addr))) { + + socklen_t addrsize=sizeof(addr); + int bindret=bind(sock,(struct sockaddr *) &addr, addrsize); + if (bindret == 0) { + we_own_log = 1; listen(sock,5); if ((pid=fork())==-1) {