From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 3007A4696C5 for ; Tue, 14 Apr 2020 14:38:41 +0300 (MSK) From: Alexander Turenko Date: Tue, 14 Apr 2020 14:38:11 +0300 Message-Id: <8f6316827be32f98d0303c07c79f5747d64e05fd.1586862436.git.alexander.turenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 02/12] popen: add ability to keep child on deletion List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org From: Cyrill Gorcunov Currently popen_delete kills all children process. Moreover we use popen_delete on tarantool exit. Alexander pointed out that keep children running even if tarantool is exited is still needed. Part of #4031 Reported-by: Alexander Turenko Acked-by: Alexander Turenko Signed-off-by: Cyrill Gorcunov --- src/lib/core/popen.c | 15 +++++++++------ src/lib/core/popen.h | 6 ++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index a5a305013..30be74a5f 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 623d826b9..570376d33 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), }; /** -- 2.25.0