From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E349D4696C4 for ; Fri, 10 Apr 2020 17:40:48 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id q19so2138985ljp.9 for ; Fri, 10 Apr 2020 07:40:48 -0700 (PDT) From: Cyrill Gorcunov Date: Fri, 10 Apr 2020 17:40:21 +0300 Message-Id: <20200410144021.5704-3-gorcunov@gmail.com> In-Reply-To: <20200410144021.5704-1-gorcunov@gmail.com> References: <20200410144021.5704-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/2] popen: add ability to keep child on deletion List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml 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. Reported-by: Alexander Turenko Signed-off-by: Cyrill Gorcunov --- src/lib/core/popen.c | 5 ++++- src/lib/core/popen.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index 200b31b21..50b40b3a4 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -489,8 +489,11 @@ popen_delete(struct popen_handle *handle) return -1; } - if (popen_send_signal(handle, SIGKILL) && errno != ESRCH) + if ((handle->flags & POPEN_FLAG_KEEP_CHILD) == 0) { + if (popen_send_signal(handle, SIGKILL) && + 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 f9dd0ff45..2e87e11ff 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 rinning on delete. + */ + POPEN_FLAG_KEEP_CHILD_BIT = 17, + POPEN_FLAG_KEEP_CHILD = (1 << POPEN_FLAG_KEEP_CHILD_BIT), }; /** -- 2.20.1