MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_pidfile_uncontested

Function test_pidfile_uncontested

tools/libutil/tests/pidfile_test.c:60–81  ·  view source on GitHub ↗

* Test that pidfile_open() can create a pidfile and that pidfile_write() * can write to it. */

Source from the content-addressed store, hash-verified

58 * can write to it.
59 */
60static const char *
61test_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.

Callers

nothing calls this directly

Calls 3

pidfile_openFunction · 0.85
pidfile_writeFunction · 0.85
pidfile_closeFunction · 0.85

Tested by

no test coverage detected