]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e842803a MB |
2 | |
3 | #include <unistd.h> | |
4 | ||
5 | #include "async.h" | |
e842803a | 6 | #include "macro.h" |
6e866b33 | 7 | #include "tmpfile-util.h" |
db2df898 | 8 | #include "util.h" |
e842803a MB |
9 | |
10 | static bool test_async = false; | |
11 | ||
12 | static void *async_func(void *arg) { | |
13 | test_async = true; | |
14 | ||
15 | return NULL; | |
16 | } | |
17 | ||
18 | int main(int argc, char *argv[]) { | |
19 | int fd; | |
20 | char name[] = "/tmp/test-asynchronous_close.XXXXXX"; | |
21 | ||
8a584da2 | 22 | fd = mkostemp_safe(name); |
e842803a MB |
23 | assert_se(fd >= 0); |
24 | asynchronous_close(fd); | |
e735f4d4 | 25 | |
e842803a | 26 | assert_se(asynchronous_job(async_func, NULL) >= 0); |
e735f4d4 | 27 | |
1d42b86d | 28 | assert_se(asynchronous_sync(NULL) >= 0); |
e842803a MB |
29 | |
30 | sleep(1); | |
31 | ||
32 | assert_se(fcntl(fd, F_GETFD) == -1); | |
33 | assert_se(test_async); | |
34 | ||
6e866b33 | 35 | (void) unlink(name); |
5eef597e | 36 | |
e842803a MB |
37 | return 0; |
38 | } |