Fei Jie | ab917ae | 2016-03-10 10:41:31 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <fcntl.h> |
| 3 | #include <sys/syscall.h> |
| 4 | |
| 5 | #if defined __NR_dup3 && defined O_CLOEXEC |
| 6 | |
| 7 | # include <errno.h> |
| 8 | # include <stdio.h> |
| 9 | # include <unistd.h> |
| 10 | |
| 11 | int |
| 12 | main(void) |
| 13 | { |
| 14 | const long int fd_old = (long int) 0xdeadbeefffffffff; |
| 15 | const long int fd_new = (long int) 0xdeadbeeffffffffe; |
Dmitry V. Levin | 22f9fa7 | 2016-04-21 20:34:56 +0000 | [diff] [blame^] | 16 | |
| 17 | long rc = syscall(__NR_dup3, fd_old, fd_new, O_CLOEXEC); |
| 18 | printf("dup3(%d, %d, O_CLOEXEC) = %ld %s (%m)\n", |
| 19 | (int) fd_old, (int) fd_new, rc, errno2name()); |
Fei Jie | ab917ae | 2016-03-10 10:41:31 +0800 | [diff] [blame] | 20 | |
| 21 | puts("+++ exited with 0 +++"); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | #else |
| 26 | |
| 27 | SKIP_MAIN_UNDEFINED("__NR_dup3 && && O_CLOEXEC") |
| 28 | |
| 29 | #endif |