Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 6/7] popen: handle setsid os specifics
Date: Tue, 10 Mar 2020 20:12:52 +0300	[thread overview]
Message-ID: <20200310171252.nxim2zgghvdqkmei@tkn_work_nb> (raw)
In-Reply-To: <20200310164100.GF27301@uranus>

On Tue, Mar 10, 2020 at 07:41:00PM +0300, Cyrill Gorcunov wrote:
> On Tue, Mar 10, 2020 at 07:36:46PM +0300, Alexander Turenko wrote:
> > > It seems that setsid() is used mainly to disassociate from a controlling
> > > terminal (to don't be hit by SIGHUP if it'll die). In this context
> > > setpgrp() would not be sufficient.
> > 
> > I just realized that there is another reason to use setsid(), where
> > setpgrp() is applicable too: move the child into its own process group
> > and kill the whole group (child and its childs if any) then. I mean, use
> > the corresponding flag (which I proposed to add in [1]), which will
> > change :kill() behaviour.
> > 
> > [1]: https://lists.tarantool.org/pipermail/tarantool-patches/2020-March/014608.html
> > 
> > So, it seems, we should do ioctl() + setpgrp() on Mac OS?
> 
> The child may generate subchildren with own groups. If I'm not missing
> something obvious we should provide only basic functionality whic would
> be enough to spawn new processes. The child may generate subchildren
> with own group, serisouly without pid namespace we simply do not control
> much. Thus I propose to leave it in the state it is right now.

We don't intend to offer some kind of guaranteed isolation. A child may
spawn a daemon, yep. But we usually know what we're run and whether it
will do something like this.

We should provide a tool to do the following:

* Allow to spawn a background process, which will not die even if a
  controlling terminal died (setsid() or ioctl() solve it).
* Allow to set a new process group for a process and its childs (say,
  for a non-inveractive shell) in order to be able to kill the entire
  group if we're going to free resources (setsid() or setpgrp() solve
  it).

Usual case for the latter bullet: spawn a pipeline using "sh -c 'foo |
bar'" and be able to kill it entirely. A non-interactive shell does not
perform job control, so even "bash -c 'foo & bar'" will be killed
entirely in the case.

After looking around discussions re other popen implementations, I guess
that we'll be asked for those abilities sooner or later. It seems
logical to implement it, since we know it is expected from a popen
implementation.

WBR, Alexander Turenko.

  reply	other threads:[~2020-03-10 17:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 20:12 [Tarantool-patches] [PATCH 0/7] popen: various fixes and a test Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 1/7] core/say: Export logger fd Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 2/7] popen: allow accessing environ variable Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 3/7] popen: close_inherited_fds - add support for macos/freebsd Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 4/7] popen: log errors if popen creation failed Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 5/7] popen: add logging in child process Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 6/7] popen: handle setsid os specifics Cyrill Gorcunov
2020-03-03 11:38   ` Alexander Turenko
2020-03-03 11:45     ` Cyrill Gorcunov
2020-03-10 15:49       ` Alexander Turenko
2020-03-10 16:36         ` Alexander Turenko
2020-03-10 16:41           ` Cyrill Gorcunov
2020-03-10 17:12             ` Alexander Turenko [this message]
2020-03-10 17:40               ` Cyrill Gorcunov
2020-03-11  7:55               ` [Tarantool-patches] [PATCH v5 6/7] popen: handle sid on macos Cyrill Gorcunov
2020-03-06 14:30   ` [Tarantool-patches] [PATCH v2 6/7] popen: handle setsid os specifics Cyrill Gorcunov
2020-03-10  8:02     ` [Tarantool-patches] [PATCH v3 6/7] popen: use ioctl on macos Cyrill Gorcunov
2020-03-02 20:12 ` [Tarantool-patches] [PATCH 7/7] test/unit: add popen test Cyrill Gorcunov
2020-03-11 20:22   ` Alexander Turenko
2020-03-12 10:38     ` [Tarantool-patches] [PATCH v5 " Cyrill Gorcunov
2020-03-12 11:58 ` [Tarantool-patches] [PATCH 0/7] popen: various fixes and a test Alexander Turenko
2020-03-12 12:18   ` Cyrill Gorcunov
2020-03-16 15: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=20200310171252.nxim2zgghvdqkmei@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 6/7] popen: handle setsid os specifics' \
    /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