Mercurial > hg > toybox
comparison lib/xwrap.c @ 1028:58bfd974216d draft
syslogd: cleanup
- fix bugs introduced in the cleanups
- inline addrfds() and open_unix_socks() and simplify them
- use xpidfile()
- remove isNetwork from struct logfile
- invert the meaning of facility and level in struct logfile so
that they are automatically correctly initialized
- fix memory leak regarding the filenames of logfiles
- TT.sd was unused
author | Felix Janda <felix.janda at posteo.de> |
---|---|
date | Mon, 26 Aug 2013 21:55:33 +0200 |
parents | 252caf3d2b88 |
children | 40d0c96a8e89 |
comparison
equal
deleted
inserted
replaced
1027:4b0ad1c7af42 | 1028:58bfd974216d |
---|---|
450 pid_t pid; | 450 pid_t pid; |
451 | 451 |
452 sprintf(pidfile, "/var/run/%s.pid", name); | 452 sprintf(pidfile, "/var/run/%s.pid", name); |
453 // Try three times to open the sucker. | 453 // Try three times to open the sucker. |
454 for (i=0; i<3; i++) { | 454 for (i=0; i<3; i++) { |
455 fd = open(pidfile, O_CREAT|O_EXCL, 0644); | 455 fd = open(pidfile, O_CREAT|O_EXCL|O_WRONLY, 0644); |
456 if (fd != -1) break; | 456 if (fd != -1) break; |
457 | 457 |
458 // If it already existed, read it. Loop for race condition. | 458 // If it already existed, read it. Loop for race condition. |
459 fd = open(pidfile, O_RDONLY); | 459 fd = open(pidfile, O_RDONLY); |
460 if (fd == -1) continue; | 460 if (fd == -1) continue; |