supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: sysinit@yandex.com
To: supervision@List.skarnet.org
Subject: race condition in killall
Date: Sun, 5 May 2019 03:55:51 +0200	[thread overview]
Message-ID: <20190505015551.GF2595@panda> (raw)
In-Reply-To: <20190504060704.GA27290@CasperVector>


> pkill(1), killall(1) and killall5(8) all retrieve a process list and
> kill them one by one, instead of calling kill(-1, signal), so a race
> condition can happen thats let some process escape the final SIGKILL.

interesting. i have not considered this at all.
looks like kill( -1, sig ) from process #1 ensures correctnes here
in a cheap and simple way.
so splitting stage 3 into 2 parts seems to be a good approach.

> Since pkill(1) and killall(1) use regex matching, the probability for
> the race can be significantly larger.

since they do more work to select processes and hence need more time when
iterating the PID dirs in the procfs ?
though i doubt they use any matching at all when tasked with killing all
processes and probably behave like the killall5 utility in this situation.

OpenRC also provides a tool for that task btw:
/libexec/rc/bin/kill_all

it uses the kvm method to find running processes on the BSDs and the procfs
on Linux.



  reply	other threads:[~2019-05-05  1:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-17 13:25 Update on the progress of slew development Casper Ti. Vector
2019-03-17 14:30 ` Oliver Schad
2019-03-18 14:44   ` Casper Ti. Vector
2019-03-19 12:10     ` Casper Ti. Vector
2019-03-19 12:42   ` Casper Ti. Vector
2019-03-19 15:25     ` Casper Ti. Vector
2019-03-19 15:58     ` Oliver Schad
     [not found]       ` <20190320051439.GA7636@caspervector>
2019-03-20  5:14       ` Casper Ti. Vector
2019-03-20 11:51         ` Casper Ti. Vector
2019-05-04  6:07         ` Casper Ti. Vector
2019-05-05  1:55           ` sysinit [this message]
2019-05-07 14:46             ` race condition in killall Casper Ti. Vector
2019-05-11 18:29             ` Guillermo
2019-05-11 19:26               ` Laurent Bercot
2019-09-27 17:42 ` Update on the progress of slew development Casper Ti. Vector

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=20190505015551.GF2595@panda \
    --to=sysinit@yandex.com \
    --cc=supervision@List.skarnet.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.
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).