| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
|---|---|
| 2 | |
| 3 | #include <fcntl.h> |
| 4 | #include <stdio.h> |
| 5 | #include <unistd.h> |
| 6 | |
| 7 | int main(int, const char *[]) |
| 8 | { |
| 9 | const int fd = open(path: "testfile1", O_CREAT | O_RDWR | O_EXCL); // exclusively create a file |
| 10 | printf(format: "fd: %d\n", fd); |
| 11 | close(fd: fd); |
| 12 | |
| 13 | // then we unlink it |
| 14 | unlink(path: "testfile1"); |
| 15 | } |
| 16 |