* Test that child processes inherit the lock */
| 149 | * Test that child processes inherit the lock |
| 150 | */ |
| 151 | const char * |
| 152 | test_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 | |
| 182 | static struct test { |
| 183 | const char *name; |