summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-28 07:15:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-28 07:15:56 +0000
commit21f81885ab310f564fb60bfe7dcde816eeb11994 (patch)
treed5b3f4dc354405854a354ba1c80a0f333dc906cb /process.c
parentb3ffb68b5bacd05af67c3b8b51c9209d184e3a60 (diff)
win32.c: rb_w32_dup2
* win32/win32.c (rb_w32_dup2): extract from rb_cloexec_dup2() and redirect_dup2(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/process.c b/process.c
index c12182a..f1482c7 100644
--- a/process.c
+++ b/process.c
@@ -2500,28 +2500,16 @@ redirect_dup(int oldfd)
ttyprintf("dup(%d) => %d\n", oldfd, ret);
return ret;
}
-#else
-#define redirect_dup(oldfd) dup(oldfd)
-#endif
-#if defined(DEBUG_REDIRECT) || defined(_WIN32)
static int
redirect_dup2(int oldfd, int newfd)
{
int ret;
ret = dup2(oldfd, newfd);
- if (newfd >= 0 && newfd <= 2)
- SetStdHandle(newfd == 0 ? STD_INPUT_HANDLE : newfd == 1 ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE, (HANDLE)rb_w32_get_osfhandle(newfd));
-#if defined(DEBUG_REDIRECT)
ttyprintf("dup2(%d, %d)\n", oldfd, newfd);
-#endif
return ret;
}
-#else
-#define redirect_dup2(oldfd, newfd) dup2((oldfd), (newfd))
-#endif
-#if defined(DEBUG_REDIRECT)
static int
redirect_close(int fd)
{
@@ -2541,6 +2529,8 @@ redirect_open(const char *pathname, int flags, mode_t perm)
}
#else
+#define redirect_dup(oldfd) dup(oldfd)
+#define redirect_dup2(oldfd, newfd) dup2((oldfd), (newfd))
#define redirect_close(fd) close(fd)
#define redirect_open(pathname, flags, perm) open((pathname), (flags), (perm))
#endif