| * Copyright (C) 2007 by Stephane Billiart <stephane.billiart@gmail.com> |
| * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| /* Override ENABLE_FEATURE_PIDFILE */ |
| void FAST_FUNC write_pidfile(const char *path) |
| char buf[sizeof(int)*3 + 2]; |
| /* we will overwrite stale pidfile */ |
| pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
| /* path can be "/dev/null"! Test for such cases */ |
| wrote_pidfile = (fstat(pid_fd, &sb) == 0) && S_ISREG(sb.st_mode); |
| /* few bytes larger, but doesn't use stdio */ |
| end = utoa_to_buf(getpid(), buf, sizeof(buf)); |
| full_write(pid_fd, buf, end - buf + 1); |