Remove useless PARENT_FD/CHILD_FD hack.
This commit is contained in:
+8
-16
@@ -74,14 +74,6 @@
|
||||
|
||||
static int run_process(struct child *child, struct opts *, int[][2]);
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
# define PARENT_FD(x) ((x) ? 0 : 1)
|
||||
# define CHILD_FD(x) ((x) ? 1 : 0)
|
||||
#else
|
||||
# define PARENT_FD(x) 0
|
||||
# define CHILD_FD(x) 1
|
||||
#endif
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
static void rep32(uint8_t *buf, void *addr);
|
||||
static int dll_inject(PROCESS_INFORMATION *, char const *);
|
||||
@@ -105,9 +97,9 @@ int myfork(struct child *child, struct opts *opts)
|
||||
/* The pipe is created with NOINHERIT otherwise both parts are
|
||||
* inherited. We then duplicate the part we want. */
|
||||
ret = _pipe(pipes[i], 512, _O_BINARY | O_NOINHERIT);
|
||||
tmp = _dup(pipes[i][CHILD_FD(i)]);
|
||||
close(pipes[i][CHILD_FD(i)]);
|
||||
pipes[i][CHILD_FD(i)] = tmp;
|
||||
tmp = _dup(pipes[i][1]);
|
||||
close(pipes[i][1]);
|
||||
pipes[i][1] = tmp;
|
||||
#endif
|
||||
if(ret < 0)
|
||||
{
|
||||
@@ -127,8 +119,8 @@ int myfork(struct child *child, struct opts *opts)
|
||||
child->pid = pid;
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
close(pipes[i][CHILD_FD(i)]);
|
||||
child->fd[i] = pipes[i][PARENT_FD(i)];
|
||||
close(pipes[i][1]);
|
||||
child->fd[i] = pipes[i][0];
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -279,9 +271,9 @@ static int run_process(struct child *child, struct opts *opts, int pipes[][2])
|
||||
/* Inherit standard handles */
|
||||
memset(&sinfo, 0, sizeof(sinfo));
|
||||
sinfo.cb = sizeof(sinfo);
|
||||
sinfo.hStdInput = (HANDLE)_get_osfhandle(pipes[0][CHILD_FD(0)]);
|
||||
sinfo.hStdOutput = (HANDLE)_get_osfhandle(pipes[1][CHILD_FD(1)]);
|
||||
sinfo.hStdError = (HANDLE)_get_osfhandle(pipes[2][CHILD_FD(2)]);
|
||||
sinfo.hStdInput = INVALID_HANDLE_VALUE;
|
||||
sinfo.hStdOutput = (HANDLE)_get_osfhandle(pipes[2][1]);
|
||||
sinfo.hStdError = (HANDLE)_get_osfhandle(pipes[1][1]);
|
||||
sinfo.dwFlags = STARTF_USESTDHANDLES;
|
||||
|
||||
/* Build the commandline */
|
||||
|
||||
Reference in New Issue
Block a user