1 #if !defined(_GNU_SOURCE)
2 #define _GNU_SOURCE
3 #endif
4
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdarg.h>
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <sys/syscall.h>
11 #include <unistd.h>
12
close(int fd)13 int close(int fd) {
14 if (fd == 1022 || fd == 1023) {
15 return 0;
16 }
17 return syscall(__NR_close, fd);
18 }
19
fcntl(int __fd,int __cmd,...)20 int fcntl(int __fd, int __cmd, ...) {
21 va_list ap;
22 va_start(ap, __cmd);
23 int a1 = va_arg(ap, int);
24 int a2 = va_arg(ap, int);
25 int a3 = va_arg(ap, int);
26 int a4 = va_arg(ap, int);
27 va_end(ap);
28
29 if (__fd == 1022 || __fd == 1023) {
30 if (__cmd == F_SETFD) {
31 a1 &= ~(FD_CLOEXEC);
32 }
33 }
34
35 return syscall(__NR_fcntl, __fd, __cmd, a1, a2, a3, a4);
36 }
37