blob: b57f05a6b2fd1f401afd8e3781902dc0d970e632 [file] [log] [blame]
Fei Jieab917ae2016-03-10 10:41:31 +08001#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
11int
12main(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
27SKIP_MAIN_UNDEFINED("__NR_dup3 && && O_CLOEXEC")
28
29#endif