Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Konstantin Osipov <kostja.osipov@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	tml <tarantool-patches@dev.tarantool.org>,
	Kirill Yukhin <kyukhin@tarantool.org>,
	Igor Munkin <imun@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v6 2/4] popen: Introduce a backend engine
Date: Fri, 20 Dec 2019 15:11:52 +0300	[thread overview]
Message-ID: <20191220121152.mts76z3frywkej2e@tkn_work_nb> (raw)
In-Reply-To: <20191220081159.GG30445@atlas>

> > +	if (handle->flags & POPEN_FLAGS_SETSID) {
> > +		if (signo == SIGKILL || signo == SIGTERM) {
> > +			say_debug("popen: killpg %d signo %d",
> > +				  handle->pid, signo);
> > +			ret = killpg(handle->pid, signo);
> 
> I don't understand why you need to use killpg() here.
> 
> Could you please explain?
> I suspect that you don't, you're just trying to be safe,
> and there is no need to.

I guess it is quite common to call setsid() in a child to then able to
kill a process group at whole, based on the note:

> Note: If you need to modify the environment for the child use the env
> parameter rather than doing it in a preexec_fn. The start_new_session
> parameter can take the place of a previously common use of preexec_fn
> to call os.setsid() in the child. 

https://docs.python.org/3.9/library/subprocess.html

It is quite useful when a shell is called: a non-interactive shell does
not perform job control and so does not create a separate process group
for a command pipeline.

I googled a bit to verify that os.setsid() is actually often suggested
with subprocess.Popen() and, yep, this is so:
https://stackoverflow.com/a/4791612/1598057

I think that it is okay to be a default behaviour (because it is
harmless even for a singleton command). I guess that Python's API does
not enable it default for historical reasons.

OTOH, this behaviour means that we need to kill all spawned groups at
tarantool exit, because they will not be killed with, say, SIGINT from a
terminal (I didn't verify whether the current implementation does it).

WBR, Alexander Turenko.

  parent reply	other threads:[~2019-12-20 12:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 12:54 [Tarantool-patches] [PATCH v6 0/4] popen: Add ability to run external process Cyrill Gorcunov
2019-12-17 12:54 ` [Tarantool-patches] [PATCH v6 1/4] coio: Export helpers and provide coio_read_fd_timeout Cyrill Gorcunov
2019-12-20  7:48   ` Konstantin Osipov
2019-12-20 14:50     ` Cyrill Gorcunov
2019-12-17 12:54 ` [Tarantool-patches] [PATCH v6 2/4] popen: Introduce a backend engine Cyrill Gorcunov
2019-12-20  8:11   ` Konstantin Osipov
2019-12-20 11:52     ` Cyrill Gorcunov
2019-12-20 12:04       ` Konstantin Osipov
2019-12-20 12:10         ` Cyrill Gorcunov
2019-12-20 12:11     ` Alexander Turenko [this message]
2019-12-26  7:14   ` Konstantin Osipov
2019-12-26  7:19     ` Cyrill Gorcunov
2020-01-09 11:23     ` Cyrill Gorcunov
2019-12-17 12:54 ` [Tarantool-patches] [PATCH v6 3/4] popen/lua: Add popen module Cyrill Gorcunov
2019-12-20 15:41   ` Maxim Melentiev
2019-12-17 12:54 ` [Tarantool-patches] [PATCH v6 4/4] popen/test: Add base test cases Cyrill Gorcunov

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=20191220121152.mts76z3frywkej2e@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=imun@tarantool.org \
    --cc=kostja.osipov@gmail.com \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v6 2/4] popen: Introduce a backend engine' \
    /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