]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e6b5c5d0 RC |
2 | /*** |
3 | This file is part of systemd | |
4 | ||
5 | Copyright 2014 Ronny Chevalier | |
e6b5c5d0 RC |
6 | ***/ |
7 | ||
8 | #include <unistd.h> | |
9 | ||
10 | #include "async.h" | |
0d39fa9c | 11 | #include "fileio.h" |
e6b5c5d0 | 12 | #include "macro.h" |
0d39fa9c | 13 | #include "util.h" |
e6b5c5d0 RC |
14 | |
15 | static bool test_async = false; | |
16 | ||
17 | static void *async_func(void *arg) { | |
18 | test_async = true; | |
19 | ||
20 | return NULL; | |
21 | } | |
22 | ||
23 | int main(int argc, char *argv[]) { | |
24 | int fd; | |
25 | char name[] = "/tmp/test-asynchronous_close.XXXXXX"; | |
26 | ||
646853bd | 27 | fd = mkostemp_safe(name); |
e6b5c5d0 RC |
28 | assert_se(fd >= 0); |
29 | asynchronous_close(fd); | |
c1d630d5 | 30 | |
e6b5c5d0 | 31 | assert_se(asynchronous_job(async_func, NULL) >= 0); |
c1d630d5 | 32 | |
d00c2631 | 33 | assert_se(asynchronous_sync(NULL) >= 0); |
e6b5c5d0 RC |
34 | |
35 | sleep(1); | |
36 | ||
37 | assert_se(fcntl(fd, F_GETFD) == -1); | |
38 | assert_se(test_async); | |
39 | ||
1f532d7e RC |
40 | unlink(name); |
41 | ||
e6b5c5d0 RC |
42 | return 0; |
43 | } |