zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Chris Down <chris@chrisdown.name>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH ALTERNATE] builtins: kill: Do not set signal on current pgroup when pid is empty
Date: Sat, 15 Feb 2020 14:10:04 +0000	[thread overview]
Message-ID: <20200215141004.2e68a381@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20200215135248.GA662294@chrisdown.name>

Chris Down wrote on Sat, 15 Feb 2020 09:52 -0400:
> There are two ways to solve this issue:
> 
> 1. Add special handling to `kill` to avoid this case. See this patch[0]
>    for a version that does that.
> 2. Change how isanum behaves. Since the only two call sites that use it
>    both seem like they should handle the case where the input char array
>    is empty, that seems like a reasonable overall change to me, but
>    either works.

Thanks for the patch and the revisions.  I prefer #2.  If no one
objects (or says POSIX requires «kill ''» to be equivalent to
«kill 0»…) I'll apply it.

It would be nice to have a regression test for this.
Test/C03traps.ztst has the examples, but the test should be added to
a B*.ztst file (probably a new one).  Would you happen to have time to
look into this?  No worries if not.

Cheers,

Daniel

> After this patch:
> 
>     % trap 'exit 5' TERM
>     % kill ''
>     kill: illegal pid:
> 
> 0: https://www.zsh.org/mla/workers/2020/msg00251.html
> ---
>  Src/jobs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Src/jobs.c b/Src/jobs.c
> index e7438251e..0485f2c7c 100644
> --- a/Src/jobs.c
> +++ b/Src/jobs.c
> @@ -1854,13 +1854,14 @@ scanjobs(void)
>  
>  /* This simple function indicates whether or not s may represent      *
>   * a number.  It returns true iff s consists purely of digits and     *
> - * minuses.  Note that minus may appear more than once, and the empty *
> - * string will produce a `true' response.                             */
> + * minuses.  Note that minus may appear more than once.               */
>  
>  /**/
>  static int
>  isanum(char *s)
>  {
> +    if (*s == '\0')
> +	return 0;
>      while (*s == '-' || idigit(*s))
>  	s++;
>      return *s == '\0';


  reply	other threads:[~2020-02-15 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 15:15 [PATCH] builtins: kill: Do not set signal on current shell " Chris Down
2020-02-14 16:02 ` Chris Down
2020-02-15 13:52 ` [PATCH ALTERNATE] builtins: kill: Do not set signal on current pgroup " Chris Down
2020-02-15 14:10   ` Daniel Shahaf [this message]
2020-02-15 15:15     ` Chris Down

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=20200215141004.2e68a381@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=chris@chrisdown.name \
    --cc=zsh-workers@zsh.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).