aboutsummaryrefslogtreecommitdiff
path: root/src/lib/process
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/process')
-rw-r--r--src/lib/process/process_unix.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/process/process_unix.c b/src/lib/process/process_unix.c
index 4fc1b7a519..57ca69a768 100644
--- a/src/lib/process/process_unix.c
+++ b/src/lib/process/process_unix.c
@@ -112,16 +112,6 @@ process_unix_free_(process_unix_t *unix_process)
/* FIXME(ahf): Refactor waitpid code? */
unix_process->waitpid = NULL;
- /* Cleanup our events. */
- if (! unix_process->stdout_handle.reached_eof)
- process_unix_stop_reading(&unix_process->stdout_handle);
-
- if (! unix_process->stderr_handle.reached_eof)
- process_unix_stop_reading(&unix_process->stderr_handle);
-
- if (unix_process->stdin_handle.is_writing)
- process_unix_stop_writing(&unix_process->stdin_handle);
-
/* Close all our file descriptors. */
process_unix_close_file_descriptors(unix_process);
@@ -668,6 +658,17 @@ process_unix_close_file_descriptors(process_unix_t *unix_process)
int ret;
bool success = true;
+ /* Stop reading and writing before we close() our
+ * file descriptors. */
+ if (! unix_process->stdout_handle.reached_eof)
+ process_unix_stop_reading(&unix_process->stdout_handle);
+
+ if (! unix_process->stderr_handle.reached_eof)
+ process_unix_stop_reading(&unix_process->stderr_handle);
+
+ if (unix_process->stdin_handle.is_writing)
+ process_unix_stop_writing(&unix_process->stdin_handle);
+
if (unix_process->stdin_handle.fd != -1) {
ret = close(unix_process->stdin_handle.fd);
if (ret == -1) {