OLD | NEW |
1 #include <unistd.h> | 1 #include <unistd.h> |
2 #include <errno.h> | 2 #include <errno.h> |
3 #include <fcntl.h> | 3 #include <fcntl.h> |
4 #include "syscall.h" | 4 #include "syscall.h" |
5 | 5 |
6 int dup2(int old, int new) | 6 int dup2(int old, int new) { |
7 { | 7 int r; |
8 » int r; | |
9 #ifdef SYS_dup2 | 8 #ifdef SYS_dup2 |
10 » while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); | 9 while ((r = __syscall(SYS_dup2, old, new)) == -EBUSY) |
| 10 ; |
11 #else | 11 #else |
12 » if (old==new) { | 12 if (old == new) { |
13 » » r = __syscall(SYS_fcntl, old, F_GETFD); | 13 r = __syscall(SYS_fcntl, old, F_GETFD); |
14 » » if (r >= 0) return old; | 14 if (r >= 0) |
15 » } else { | 15 return old; |
16 » » while ((r=__syscall(SYS_dup3, old, new, 0))==-EBUSY); | 16 } else { |
17 » } | 17 while ((r = __syscall(SYS_dup3, old, new, 0)) == -EBUSY) |
| 18 ; |
| 19 } |
18 #endif | 20 #endif |
19 » return __syscall_ret(r); | 21 return __syscall_ret(r); |
20 } | 22 } |
OLD | NEW |