diff options
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r-- | libbb/xfuncs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 64061e4f0..5a1090eaf 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -169,13 +169,18 @@ int ndelay_off(int fd) | |||
169 | return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); | 169 | return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); |
170 | } | 170 | } |
171 | 171 | ||
172 | void xdup2(int from, int to) | ||
173 | { | ||
174 | if (dup2(from, to) != to) | ||
175 | bb_perror_msg_and_die("can't duplicate file descriptor"); | ||
176 | } | ||
177 | |||
172 | // "Renumber" opened fd | 178 | // "Renumber" opened fd |
173 | void xmove_fd(int from, int to) | 179 | void xmove_fd(int from, int to) |
174 | { | 180 | { |
175 | if (from == to) | 181 | if (from == to) |
176 | return; | 182 | return; |
177 | if (dup2(from, to) != to) | 183 | xdup2(from, to); |
178 | bb_perror_msg_and_die("can't duplicate file descriptor"); | ||
179 | close(from); | 184 | close(from); |
180 | } | 185 | } |
181 | 186 | ||