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

Function test_flopen_lock_child

tools/libutil/tests/flopen_test.c:151–180  ·  view source on GitHub ↗

* Test that child processes inherit the lock */

Source from the content-addressed store, hash-verified

149 * Test that child processes inherit the lock
150 */
151const char *
152test_flopen_lock_child(void)
153{
154 const char *fn = "test_flopen_lock_child";
155 const char *result = NULL;
156 pid_t pid;
157 volatile int fd1, fd2;
158
159 unlink(fn);
160 fd1 = flopen(fn, O_RDWR|O_CREAT, 0640);
161 if (fd1 < 0) {
162 result = strerror(errno);
163 } else {
164 pid = fork();
165 if (pid == -1) {
166 result = strerror(errno);
167 } else if (pid == 0) {
168 select(0, 0, 0, 0, 0);
169 _exit(0);
170 }
171 close(fd1);
172 if ((fd2 = flopen(fn, O_RDWR|O_NONBLOCK)) != -1) {
173 result = "second open succeeded";
174 close(fd2);
175 }
176 kill(pid, SIGINT);
177 }
178 unlink(fn);
179 return (result);
180}
181
182static struct test {
183 const char *name;

Callers

nothing calls this directly

Calls 4

flopenFunction · 0.85
selectFunction · 0.85
killFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected