From: Alexander Turenko <alexander.turenko@tarantool.org> To: Cyrill Gorcunov <gorcunov@gmail.com> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 10/12] popen: add FIXME re group signal flaw Date: Wed, 15 Apr 2020 07:21:23 +0300 [thread overview] Message-ID: <20200415042123.k5nq2wcdx4xi52mj@tkn_work_nb> (raw) In-Reply-To: <20200414131910.GI3072@uranus> On Tue, Apr 14, 2020 at 04:19:10PM +0300, Cyrill Gorcunov wrote: > On Tue, Apr 14, 2020 at 02:38:19PM +0300, Alexander Turenko wrote: > > It is convenient to have such anchors for known problems. > > > > Part of #4031 > Acked-by: Cyrill Gorcunov <gorcunov@gmail.com> > > Actually I need to think about all this more. But I think > it is safe to merge now. I think about it more and also briefly discussed with Cyrill. It seems this problem is a kind of fundamental and we should explain it in the documentation comments rather than mark to fix later. So I rewrote the commit in this way: commit 234b184ffdd9dce234520643f12fec12bbc9fa1a Author: Alexander Turenko <alexander.turenko@tarantool.org> Date: Mon Apr 13 13:37:55 2020 +0300 popen: clarify group signaling details Even when ..._SETSID and ..._GROUP_SIGNAL are set, we unable to safely kill a process group after the child process we spawned becomes died. So we don't do that. The behaviour seems to be indefeasible part of Unix process group design. The best that we can do here is describe those details in the documentation comment. NB: It seems that pid namespaces allow to overcome this problem, however it is the Linux specific feature, so we unlikely will use them. Part of #4031 diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index 411aad03b..5cd7926d1 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -539,6 +539,13 @@ popen_state_str(unsigned int state) * When POPEN_FLAG_GROUP_SIGNAL is set the function sends * a signal to a process group rather than a process. * + * A signal will not be sent if the child process is already + * dead: otherwise we might kill another process that occupies + * the same PID later. This means that if the child process + * dies before its own childs, the function will not send a + * signal to the process group even when ..._SETSID and + * ..._GROUP_SIGNAL are set. + * * Return 0 at success or -1 at failure (and set a diag). * * Possible errors: @@ -597,6 +604,8 @@ popen_send_signal(struct popen_handle *handle, int signo) * - Remove the handle from a living list. * - Free all occupied memory. * + * @see popen_send_signal() for note about ..._GROUP_SIGNAL. + * * Return 0 at success and -1 at failure (and set a diag). * * Possible errors: diff --git a/src/lib/core/popen.h b/src/lib/core/popen.h index 4cdd95175..8cb71e28d 100644 --- a/src/lib/core/popen.h +++ b/src/lib/core/popen.h @@ -99,6 +99,8 @@ enum popen_flag_bits { /* * Send signal to a process group. + * + * @see popen_send_signal() for details. */ POPEN_FLAG_GROUP_SIGNAL_BIT = 16, POPEN_FLAG_GROUP_SIGNAL = (1 << POPEN_FLAG_GROUP_SIGNAL_BIT),
next prev parent reply other threads:[~2020-04-15 4:21 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-14 11:38 [Tarantool-patches] [PATCH 00/12] Popen Lua API: preliminary patches 2 Alexander Turenko 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 01/12] popen: allow to kill process group Alexander Turenko 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 02/12] popen: add ability to keep child on deletion Alexander Turenko 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 03/12] popen: log a reason of close inherited fds failure Alexander Turenko 2020-04-14 11:52 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 04/12] popen: add missed diag_set() in popen_new() Alexander Turenko 2020-04-14 11:54 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 05/12] popen: remove retval from popen_stat() Alexander Turenko 2020-04-14 11:54 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 06/12] popen: quote multiword command arguments Alexander Turenko 2020-04-14 11:58 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 07/12] popen: add logging of duplicated logger fd Alexander Turenko 2020-04-14 11:58 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 08/12] popen: fix close-on-exec flag setting Alexander Turenko 2020-04-14 12:03 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 09/12] popen: clarify popen_{signal, delete} contract Alexander Turenko 2020-04-14 12:29 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 10/12] popen: add FIXME re group signal flaw Alexander Turenko 2020-04-14 13:19 ` Cyrill Gorcunov 2020-04-15 4:21 ` Alexander Turenko [this message] 2020-04-15 7:27 ` Cyrill Gorcunov 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 11/12] popen: clarify popen_read_timeout error message Alexander Turenko 2020-04-14 12:32 ` Cyrill Gorcunov 2020-04-15 4:21 ` Alexander Turenko 2020-04-15 7:39 ` Cyrill Gorcunov 2020-04-15 21:45 ` Alexander Turenko 2020-04-14 11:38 ` [Tarantool-patches] [PATCH 12/12] popen: allow to close parent's end of std* fds Alexander Turenko 2020-04-14 13:05 ` Cyrill Gorcunov 2020-04-15 4:21 ` Alexander Turenko 2020-04-15 7:43 ` Cyrill Gorcunov 2020-04-15 21:45 ` Alexander Turenko 2020-04-15 4:25 ` [Tarantool-patches] [PATCH 13/13] popen: add caution comment for popen_may_io() Alexander Turenko 2020-04-15 7:44 ` Cyrill Gorcunov 2020-04-15 4:52 ` [Tarantool-patches] [PATCH 14/14] popen: fix popen_write_timeout retval type Alexander Turenko 2020-04-15 23:57 ` [Tarantool-patches] [PATCH 00/12] Popen Lua API: preliminary patches 2 Alexander Turenko 2020-04-16 0:00 ` Alexander Turenko 2020-04-16 11:52 ` Cyrill Gorcunov 2020-04-17 6:58 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200415042123.k5nq2wcdx4xi52mj@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 10/12] popen: add FIXME re group signal flaw' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox