* Test that flopen() can lock against itself */
| 92 | * Test that flopen() can lock against itself |
| 93 | */ |
| 94 | const char * |
| 95 | test_flopen_lock_self(void) |
| 96 | { |
| 97 | const char *fn = "test_flopen_lock_self"; |
| 98 | const char *result = NULL; |
| 99 | int fd1, fd2; |
| 100 | |
| 101 | unlink(fn); |
| 102 | fd1 = flopen(fn, O_RDWR|O_CREAT, 0640); |
| 103 | if (fd1 < 0) { |
| 104 | result = strerror(errno); |
| 105 | } else { |
| 106 | fd2 = flopen(fn, O_RDWR|O_NONBLOCK); |
| 107 | if (fd2 >= 0) { |
| 108 | result = "second open succeeded"; |
| 109 | close(fd2); |
| 110 | } |
| 111 | close(fd1); |
| 112 | } |
| 113 | unlink(fn); |
| 114 | return (result); |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * Test that flopen() can lock against other processes |