unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67132: [Shepherd] Bogus value from PID file can prevent service from being stopped
@ 2023-11-12 17:45 Ludovic Courtès
  2023-11-22 10:16 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ludovic Courtès @ 2023-11-12 17:45 UTC (permalink / raw)
  To: 67132

Hi,

‘terminate-process’ in (shepherd service) assumes that, once it has sent
SIGKILL to a given PID, it eventually gets a SIGCHLD notification for
that PID.

Unfortunately there are corner cases where it doesn’t hold.  Take PID 2:

--8<---------------cut here---------------start------------->8---
$ ps x 2
  PID TTY      STAT   TIME COMMAND
    2 ?        S      0:00 [kthreadd]
--8<---------------cut here---------------end--------------->8---

That’s not a “real” process, so when you (kill 2 SIGKILL), nothing
happens.  Thus, ‘terminate-process’ never returns; the corresponding
service stays in “stopping” state and you cannot halt your machine.

You may wonder how we end up calling ‘terminate-process’ with a “bogus”
PID.  It normally never happens, but it can happen with a combination of
‘make-forkexec-constructor’ with #:pid-file and
‘least-authority-wrapper’: the PID file of the wrapper may read “2” (the
PID inside the least-authority PID namespace), so ‘herd stop’ on that
service will end up doing (kill 2 SIGKILL).

Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#67132: [Shepherd] Bogus value from PID file can prevent service from being stopped
  2023-11-12 17:45 bug#67132: [Shepherd] Bogus value from PID file can prevent service from being stopped Ludovic Courtès
@ 2023-11-22 10:16 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2023-11-22 10:16 UTC (permalink / raw)
  To: 67132-done

Ludovic Courtès <ludo@gnu.org> skribis:

> ‘terminate-process’ in (shepherd service) assumes that, once it has sent
> SIGKILL to a given PID, it eventually gets a SIGCHLD notification for
> that PID.
>
> Unfortunately there are corner cases where it doesn’t hold.  Take PID 2:
>
> $ ps x 2
>   PID TTY      STAT   TIME COMMAND
>     2 ?        S      0:00 [kthreadd]
>
> That’s not a “real” process, so when you (kill 2 SIGKILL), nothing
> happens.  Thus, ‘terminate-process’ never returns; the corresponding
> service stays in “stopping” state and you cannot halt your machine.

Fixed in Shepherd commit cc9c5c029534458ae547d78200b6b51f729654e3.

Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-22 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-12 17:45 bug#67132: [Shepherd] Bogus value from PID file can prevent service from being stopped Ludovic Courtès
2023-11-22 10:16 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).