diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-14 06:52:29 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-10 19:28:26 +1000 |
commit | 0e9b2733fa46bb92178a832d85c0773ce16814af (patch) | |
tree | 53b2293a56ce393a01eabb2fdb69711b21f224a3 | |
parent | 20f590615177543c0d52959516c7984e48397c9b (diff) | |
download | busybox-w32-0e9b2733fa46bb92178a832d85c0773ce16814af.tar.gz busybox-w32-0e9b2733fa46bb92178a832d85c0773ce16814af.tar.bz2 busybox-w32-0e9b2733fa46bb92178a832d85c0773ce16814af.zip |
win32: Work around for dup2
Original dup2() does not return the fdto.
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | win32/mingw.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h index a828bd835..ed718fb5d 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -258,6 +258,7 @@ IMPL(strptime,char*,NULL,const char *s UNUSED_PARAM, const char *format UNUSED_P | |||
258 | IMPL(alarm,unsigned int,0,unsigned int seconds UNUSED_PARAM); | 258 | IMPL(alarm,unsigned int,0,unsigned int seconds UNUSED_PARAM); |
259 | NOIMPL(chown,const char *path UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); | 259 | NOIMPL(chown,const char *path UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); |
260 | NOIMPL(chroot,const char *root UNUSED_PARAM); | 260 | NOIMPL(chroot,const char *root UNUSED_PARAM); |
261 | int mingw_dup2 (int fd, int fdto); | ||
261 | char *mingw_getcwd(char *pointer, int len); | 262 | char *mingw_getcwd(char *pointer, int len); |
262 | 263 | ||
263 | 264 | ||
@@ -293,6 +294,7 @@ static inline void sync(void) {} | |||
293 | int mingw_unlink(const char *pathname); | 294 | int mingw_unlink(const char *pathname); |
294 | NOIMPL(vfork,void); | 295 | NOIMPL(vfork,void); |
295 | 296 | ||
297 | #define dup2 mingw_dup2 | ||
296 | #define getcwd mingw_getcwd | 298 | #define getcwd mingw_getcwd |
297 | #define lchown(a,b,c) chown(a,b,c) | 299 | #define lchown(a,b,c) chown(a,b,c) |
298 | #define open mingw_open | 300 | #define open mingw_open |
diff --git a/win32/mingw.c b/win32/mingw.c index e8096b5bc..e4ff14357 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -149,6 +149,13 @@ FILE *mingw_fopen (const char *filename, const char *mode) | |||
149 | return fopen(filename, mode); | 149 | return fopen(filename, mode); |
150 | } | 150 | } |
151 | 151 | ||
152 | #undef dup2 | ||
153 | int mingw_dup2 (int fd, int fdto) | ||
154 | { | ||
155 | int ret = dup2(fd, fdto); | ||
156 | return ret != -1 ? fdto : -1; | ||
157 | } | ||
158 | |||
152 | static inline time_t filetime_to_time_t(const FILETIME *ft) | 159 | static inline time_t filetime_to_time_t(const FILETIME *ft) |
153 | { | 160 | { |
154 | long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; | 161 | long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; |