* Test that pidfile_open() can create a pidfile and that pidfile_write() * can write to it. */
| 58 | * can write to it. |
| 59 | */ |
| 60 | static const char * |
| 61 | test_pidfile_uncontested(void) |
| 62 | { |
| 63 | const char *fn = "test_pidfile_uncontested"; |
| 64 | struct pidfh *pf; |
| 65 | pid_t other = 0; |
| 66 | |
| 67 | unlink(fn); |
| 68 | pf = pidfile_open(fn, 0600, &other); |
| 69 | if (pf == NULL && other != 0) |
| 70 | return ("pidfile exists and is locked"); |
| 71 | if (pf == NULL) |
| 72 | return (strerror(errno)); |
| 73 | if (pidfile_write(pf) != 0) { |
| 74 | pidfile_close(pf); |
| 75 | unlink(fn); |
| 76 | return ("failed to write PID"); |
| 77 | } |
| 78 | pidfile_close(pf); |
| 79 | unlink(fn); |
| 80 | return (NULL); |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Test that pidfile_open() locks against self. |
nothing calls this directly
no test coverage detected