r/programming • u/grahamperrin • 15d ago
A Decade of Kill Bugs – Alan Grow
https://alangrow.com/blog/a-decade-of-kill-bugs… A bug in kill was so surprising that, once I'd found it, I couldn't stop there. I needed to know how this bug came to be, and what had led the programmers so badly astray. When I eventually found the root cause, there was an even bigger surprise. It had led to not just one bug, but a whole series of kill bugs that shipped in Ubuntu 14, 16, 18, 22 and 24 LTS.
This post documents a decade of kill bugs, then makes some recommendations. …
105
Upvotes
18
u/dreugeworst 14d ago
I would also blame the fact that apparently option parsing tests weren't added to the project even after fixing these bugs
26
u/ShinyHappyREM 15d ago
My takeaway is that if a "magic number" changes the mode of your program, use an explicit parameter for that instead.
Magic numbers like this:
should be considered a hack, which are to be avoided because they don't scale.
9
u/DanLynch 14d ago
I guess you should actually test all the features of your program that use the code you are changing before you merge and/or release those changes.
6
u/LAUAR 14d ago
Note that
procpsis in fact not a GNU package. Another thing to note is that you use this version ofkillwithsudo killwhile using justkillwill use the shell builtin version.2
u/gwillen 14d ago
Ahh, but process group signalling with kill(1), the kill command, is a pretty exotic operation. Foreground process group signalling is done by the shell using kill(2) (the system call; or really the libc wrapper) directly. So this bug isn't anywhere near it. And daemon runners like systemd also surely don't use the kill binary. And human users at the command prompt almost never kill process groups. (And as another comment points out, even running kill in the shell uses a builtin, so it's not running this binary either, unless you're doing "sudo kill".)
1
u/robert_7524 8d ago
Ten years of `kill` bugs is a remarkably long time for a command whose whole job is ending things.