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; |
| 16 | int rc = syscall(__NR_dup3, fd_old, fd_new, O_CLOEXEC); |
| 17 | printf("dup3(%d, %d, O_CLOEXEC) = %d %s (%m)\n", |
| 18 | (int) fd_old, (int) fd_new, rc, |
| 19 | errno == ENOSYS ? "ENOSYS" : "EBADF"); |
| 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 |