diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index a5a30501325da0692aee7d152b1138229c4257e8..30be74a5f032f772079b32e5db9cc9a70d0e80e2 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -585,12 +585,15 @@ popen_delete(struct popen_handle *handle) assert(handle != NULL); - /* - * Unable to kill the process -- give an error. - * The process is not exist already -- pass over. - */ - if (popen_send_signal(handle, SIGKILL) != 0 && errno != ESRCH) - return -1; + if ((handle->flags & POPEN_FLAG_KEEP_CHILD) == 0) { + /* + * Unable to kill the process -- give an error. + * The process is not exist already -- pass over. + */ + if (popen_send_signal(handle, SIGKILL) != 0 && + errno != ESRCH) + return -1; + } for (i = 0; i < lengthof(handle->ios); i++) { if (handle->ios[i].fd != -1) diff --git a/src/lib/core/popen.h b/src/lib/core/popen.h index 623d826b9ce0278f9734c347a1fc66bd892bcc71..570376d33c5cf42caafdeb3bf2a0663d8dc6d785 100644 --- a/src/lib/core/popen.h +++ b/src/lib/core/popen.h @@ -102,6 +102,12 @@ enum popen_flag_bits { */ POPEN_FLAG_GROUP_SIGNAL_BIT = 16, POPEN_FLAG_GROUP_SIGNAL = (1 << POPEN_FLAG_GROUP_SIGNAL_BIT), + + /* + * Keep child running on delete. + */ + POPEN_FLAG_KEEP_CHILD_BIT = 17, + POPEN_FLAG_KEEP_CHILD = (1 << POPEN_FLAG_KEEP_CHILD_BIT), }; /**