mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Askar Safin <safinaskar@zohomail.com>
Cc: musl <musl@lists.openwall.com>
Subject: Re: [musl] [bug] Ctrl-Z when process is doing posix_spawn makes the process hard to kill
Date: Sat, 18 Jan 2025 06:17:02 -0500	[thread overview]
Message-ID: <20250118111702.GM10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <1947568343c.4b19ad8c16088.1387564150395328587@zohomail.com>

On Fri, Jan 17, 2025 at 09:55:50PM +0400, Askar Safin wrote:
> Thanks a lot for answer!
> 
>  ---- On Fri, 17 Jan 2025 10:37:09 +0400  Rich Felker  wrote --- 
>  > Note that SIGSTOP, which is not blockable interceptible or ignorable,
>  > can't be handled this way, but the pid has not yet leaked to anything
>  > at this point, so the only way SIGSTOP can be generated is by a badly
>  > behaved program signaling random pids, which is not a case that needs
>  > to be handled gracefully.
> 
> But what if somebody sends SIGSTOP to whole process group using kill(2)?
> 
> The bug is not reproducible with fork. Maybe this is kernel bug and should be
> forwarded there instead?

I don't understand what you think the kernel bug is. AFAICT it's
behaving exactly as it should. The spawn impl just isn't using the
kernel primitives exactly right.

Since SIGSTOP is an issue, I don't think my previous idea of using
no-op signal handlers makes sense. We'll have to handle an unblockable
stop situation anyway so might as well use the same for blockable
stops.

So, I think the parent, while waiting for the fd close event from the
child, also needs to watch for child status change to stopped, and if
this happens, send SIGCONT. This is unfortunately gratuitously
difficult, since we don't have a primitive to wait for
fd-activity-or-pid-activity short of depending on pidf (if this even
works; does pidfd poll readable for transition to stopped state?).

If there is a working pidfd approach, I guess we should use that, and
fallback to polling with short timeout and doing a waitpid/WNOHANG
between polls if pidfd isn't obtainable.

Rich

  parent reply	other threads:[~2025-01-18 11:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 23:14 Askar Safin
2025-01-17  6:37 ` Rich Felker
2025-01-17  6:46   ` Rich Felker
2025-01-17 17:55   ` Askar Safin
2025-01-18  9:51     ` Florian Weimer
2025-01-18 10:23       ` Rich Felker
2025-01-18 11:13         ` Florian Weimer
2025-01-18 20:58           ` Askar Safin
2025-01-18 11:17     ` Rich Felker [this message]
2025-01-18 20:16       ` Markus Wichmann
2025-01-19  3:18         ` Rich Felker
2025-01-18 20:52       ` Askar Safin
2025-01-22 21:45       ` Askar Safin

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=20250118111702.GM10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=safinaskar@zohomail.com \
    /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/musl/

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).