[Toybox] [PATCH] killall should kill scripts too.
Rob Landley
rob at landley.net
Sun Dec 17 09:20:42 PST 2017
On 12/16/2017 09:43 PM, enh wrote:
> I don't think the world is helped by having two different imperfect
> heuristics, and I do think it will cause bug reports for us.
We _do_ have two imperfect heuristics. Checking the patch you sent
you're checking an exact match for argv[0] before looking at comm, and
your basename() logic only kicks in for absolute paths. So a command run
at a relative path won't do what ubuntu's does:
$ ln -s $(which sleep) sleep
$ sleep 999 &
[1] 19487
$ ./sleep 1000 &
[2] 19490
$ killall ./sleep
[1]- Terminated sleep 999
[2]+ Terminated ./sleep 1000
Hmmm. What _is_ it doing?
$ $PWD/sleep 998 &
[1] 19916
$ sleep 1001 &
[2] 19917
$ killall $PWD/sleep
[1]- Terminated $PWD/sleep 998
[2]+ Terminated sleep 1001
Yeah, it doesn't look like it's ever taking the $PATH into account? But
then why...
$ $PWD/sleep 998 &
[1] 19945
$ sleep 1001 &
[2] 19946
$ $PWD/../sleep 998 &
bash: /home/landley/toybox/toy3/../sleep: No such file or directory
It's because it's a symlink, isn't it?
$ killall sleep
[1]- Terminated $PWD/sleep 998
[2]+ Terminated sleep 1001
$ sleep 1001 &
[1] 21634
$ $PWD/sleep 998 &
[2] 21637
$ killall $PWD/sleep
[2]+ Terminated $PWD/sleep 998
Yes it is. It's comparing the inode.
$ sleep 1001 &
[1] 21738
$ ./sleep 999 &
[2] 21739
$ killall sleep
[1]- Terminated sleep 1001
[2]+ Terminated ./sleep 999
But ONLY for paths, not for simple names.
$ sleep 1001 & ./sleep 999 &
[1] 21758
[2] 21759
$ killall ./sleep
[2]+ Terminated ./sleep 999
Including relative paths, so the x[0] == '/' test is still wrong.
Sigh. You argument that "we can't just do something easily explained but
must copy ubuntu's magic edge cases exactly" implies I need to
understand ubuntu's magic edge cases, which are nonobvious.
Rob
More information about the Toybox
mailing list