zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: "kill -STOP" as noticed in ksh93u+ gitlab
Date: Tue, 27 Feb 2024 23:52:57 -0800	[thread overview]
Message-ID: <CAH+w=7ap=kC8zhJ-b_tnnuYe-rYeCq7kE+muivcoi6AU9LJ6Ww@mail.gmail.com> (raw)
In-Reply-To: <20240228053934.cp76m7jfnhommrl3@chazelas.org>

On Tue, Feb 27, 2024 at 9:39 PM Stephane Chazelas <stephane@chazelas.org> wrote:
>
> 2024-02-27 18:04:34 -0800, Bart Schaefer:
> [...]
> > Changing the "kill" command doesn't (in zsh at least) affect the
> > "suspend" command.
[...]
> > % kill -STOP $$
> > kill: kill 605210 failed: operation not permitted
> > %
>
> I can't reproduce that on Ubuntu 22.04. The wording of that
> error suggests it's the system blocking the kill() with EPERM.

Sorry, I worded that badly.  I meant I actually DID change the kill
command.  I made the corresponding change as in the ksh93u+ diffs.
Posted without implying yet that it be used:

diff --git a/Src/jobs.c b/Src/jobs.c
index 118c5e61b..cfc783f46 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2890,7 +2890,12 @@ bin_kill(char *nam, char **argv, UNUSED(Options
ops), UNUSED(int func))
            returnval++;
        } else {
            int pid = atoi(*argv);
-           if (
+           if (pid == mypid && islogin &&
+               (sig == SIGSTOP || sig == SIGTSTP)) {
+               zwarnnam("kill", "kill %s failed: %e", *argv, errno = EPERM);
+               returnval++;
+           } else if (
+
 #ifdef HAVE_SIGQUEUE
                use_sigqueue ? sigqueue(pid, sig, sigqueue_info) :
 #endif


> If we're blocking kill -s STOP $$, should we also block kill -s
> STOP 0 and kill -s STOP -1?

That's less likely than someone starting a subshell and forgetting
that $$ doesn't mean the PID of the subshell.  And if using 0 / -1 the
intention is to signal multiple processes.

I suppose zsh could signal_block() the signal it is about to pass to
kill(), but that seems like (ahem) overkill.


      parent reply	other threads:[~2024-02-28  7:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 21:26 Bart Schaefer
2024-02-27  7:05 ` Stephane Chazelas
2024-02-28  2:04   ` Bart Schaefer
2024-02-28  5:39     ` Stephane Chazelas
2024-02-28  5:42       ` Stephane Chazelas
2024-02-28  7:52       ` Bart Schaefer [this message]

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='CAH+w=7ap=kC8zhJ-b_tnnuYe-rYeCq7kE+muivcoi6AU9LJ6Ww@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).