Hi, I came across this discussion after reading [A Decade of Kill Bugs](https://alangrow.com/blog/a-decade-of-kill-bugs) and decided to review the current [procps-ng](https://gitlab.com/procps- ng/procps/-/blob/master/src/kill.c) `kill.c` implementation.
I noticed that upstream commit `bfbaf43` fixed the original negative PID truncation. However, the implementation still depended on `getopt_long()` and `optind` state to recover negative process-group operands. The regressions documented here suggest that this approach is hard to maintain reliably. I prepared a patch which I'm attaching for review. It was actually 4 commits I merged for simplicity. It targets the underlying parsing problem instead of adding another workaround. The patch makes the following changes: * Restricts legacy `-SIGNAL` selection to the first argument and stops option parsing at the first operand, avoiding argument permutation and dependence on `optind` for negative PID recovery. * Handles positive and negative PID operands through the same execution path, including multiple targets. * Validates numeric operands against the `pid_t` range and checks all operands before signalling, so malformed values or integer narrowing cannot select unintended targets. * Adds 20 regression cases to the native DejaGnu tests, using an `LD_PRELOAD` interceptor for `kill()` and `sigqueue()` to inspect targets without delivering actual signals. * Updates `kill(1)` to document positional option parsing, `--`, and negative process-group operands. The interception helper is also registered in `EXTRA_DIST`. The patch deliberately changes some historical argument-ordering behaviour. Signal options following operands are no longer interpreted as options, and negative operands are no longer treated as additional signal selectors. I think these changes make the command's behaviour more predictable, although the compatibility implications deserve review. For validation, all 20 new regression cases passed in an isolated test harness. I also built procps-ng 4.0.7.47 locally and ran `make check`, which completed with 8 passes, zero failures, and zero errors. The man-page translation workflow first needed regenerating with `make -C po-man update-po`, after which the build succeeded. I kept the patch as a single signed-off commit covering the implementation, regression tests, and documentation. I understand that a broader parsing change may not be appropriate for an Ubuntu stable-release update. I am offering it as a longer-term upstream improvement that addresses the recurring parsing issues documented in this discussion. I would appreciate feedback on the proposed parsing semantics, particularly the compatibility implications, and whether this approach would be suitable for upstream procps-ng. Thanks! ** Patch added: "0001-kill-Fix-negative-PID-argument-handling.patch" https://bugs.launchpad.net/ubuntu/+source/procps/+bug/2166756/+attachment/6014855/+files/0001-kill-Fix-negative-PID-argument-handling.patch -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2166756 Title: [Noble SRU] procps kill truncates negative PIDs To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/procps/+bug/2166756/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
