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