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 1/2] popen: Allow to kill process group
Date: Fri, 10 Apr 2020 19:41:24 +0300	[thread overview]
Message-ID: <20200410164124.5ynh3ltaixcg66kv@tkn_work_nb> (raw)
In-Reply-To: <20200410144021.5704-2-gorcunov@gmail.com>

On Fri, Apr 10, 2020 at 05:40:20PM +0300, Cyrill Gorcunov wrote:
> As Alexander pointed out this might be useful
> for running a pipe of programs inside shell
> (i.e. popen.shell('foo | bar | baz', 'r')).
> 
> Reported-by: Alexander Turenko <alexander.turenko@tarantool.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>

Acked-by: Alexander Turenko <alexander.turenko@tarantool.org>

> @@ -443,10 +456,17 @@ popen_send_signal(struct popen_handle *handle, int signo)
>  	if (!popen_may_pidop(handle))
>  		return -1;
>  
> -	say_debug("popen: kill %d signo %d", handle->pid, signo);
> -	ret = kill(handle->pid, signo);
> +	say_debug("popen: %s %d signo %d",
> +		  handle->flags & POPEN_FLAG_GROUP_SIGNAL ?
> +		  "killpg" : "kill", handle->pid, signo);
> +	if (handle->flags & POPEN_FLAG_GROUP_SIGNAL)
> +		ret = killpg(handle->pid, signo);
> +	else
> +		ret = kill(handle->pid, signo);
>  	if (ret < 0) {
> -		diag_set(SystemError, "Unable to kill %d signo %d",
> +		diag_set(SystemError, "Unable to %s %d signo %d",
> +			 handle->flags & POPEN_FLAG_GROUP_SIGNAL ?
> +			 "killpg" : "kill",
>  			 handle->pid, signo);
>  	}

Nit: I would define a string constant, it will be easier to read I
guess.

 | const char *kill_func = handle->flags & POPEN_FLAG_GROUP_SIGNAL ?
 | 		"killpg" : "kill";

This function is changed in the 'Popen Lua API: preliminary patches'
patchset, which is pushed to master now. Need to be rebased so.

  reply	other threads:[~2020-04-10 16:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 14:40 [Tarantool-patches] [PATCH 0/2] popen: provide more flags Cyrill Gorcunov
2020-04-10 14:40 ` [Tarantool-patches] [PATCH 1/2] popen: Allow to kill process group Cyrill Gorcunov
2020-04-10 16:41   ` Alexander Turenko [this message]
2020-04-12  1:27   ` Alexander Turenko
2020-04-12  1:40     ` Alexander Turenko
2020-04-10 14:40 ` [Tarantool-patches] [PATCH 2/2] popen: add ability to keep child on deletion Cyrill Gorcunov
2020-04-10 16:45   ` Alexander Turenko

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=20200410164124.5ynh3ltaixcg66kv@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/2] popen: Allow to kill process group' \
    /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