Calling CloseHandle multiple times for the same handle can lead to
exceptions while debugging according to documentation.
Mimic the waitpid handling for success cases to behave more like the
Unix version which would "reap the zombie".
Doing this for an unsuccessful call is off, but the loop is never
entered again, so I guess it's okay and worth it to reduce the amount
of Windows specific definitions in source files.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
state->waitpid_return
= waitpid(state->child, &state->exit_status, 0);
} while (state->waitpid_return == -1 && errno == EINTR);
-#if defined(_WIN32) && !defined(__CYGWIN__)
- CloseHandle(state->child);
-#endif
state->child = 0;
}
}
} while (cs == STILL_ACTIVE);
+ CloseHandle(child);
*status = (int)(cs & 0xff);
return (0);
}
close(data->child_stdout);
while (waitpid(data->child, &status, 0) == -1 && errno == EINTR)
continue;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- CloseHandle(data->child);
-#endif
data->child = 0;
if (status != 0) {