mirror of
git://git.code.sf.net/p/zsh/code
synced 2026-01-05 09:21:13 +01:00
The following case was encountered in the wild:
% zsh; echo "$?"
% trap 'exit 5' TERM
% kill ''
5
This behaviour seems more likely to be the result of bugs in programs
(e.g. `kill -9 "$unsetvar") rather than being desirable
behaviour to me. It also seems unintentional judging by the code and
documentation, since it comes about as a result of the fact that:
- `isanum` returns true for empty strings (since an empty string
technically only consists of digits and minuses...);
- `atoi`, when passed a pointer to an invalid number, returns 0;
- `kill(0, signal)` sends the signal in question to all processes in the
current process group.
There are (at least) two ways to solve this issue:
1. Add special handling to `kill` to avoid this case. See this patch[0]
for a version that does that.
2. Change how isanum behaves. Since the only two call sites that use it
both seem like they should handle the case where the input char array
is empty, that seems like a reasonable overall change to me.[1]
After this patch:
% trap 'exit 5' TERM
% kill ''
kill: illegal pid:
The regression test for `kill` without a sigspec is also included in
this commit, as previously it's not possible to test it trivially as it
would still kill the test runner in expected-to-fail mode; see
discussion in workers/45449.
0: workers/45426: https://www.zsh.org/mla/workers/2020/msg00251.html
1: The other call site using isanum() is the fg builtin, but in that
case we just fail later since we can't find any job named '', so no
big deal either way. It's the kill case which is more concerning.
|
||
|---|---|---|
| .. | ||
| .cvsignore | ||
| .distfiles | ||
| A01grammar.ztst | ||
| A02alias.ztst | ||
| A03quoting.ztst | ||
| A04redirect.ztst | ||
| A05execution.ztst | ||
| A06assign.ztst | ||
| A07control.ztst | ||
| B01cd.ztst | ||
| B02typeset.ztst | ||
| B03print.ztst | ||
| B04read.ztst | ||
| B05eval.ztst | ||
| B06fc.ztst | ||
| B07emulate.ztst | ||
| B08shift.ztst | ||
| B09hash.ztst | ||
| B10getopts.ztst | ||
| B11kill.ztst | ||
| C01arith.ztst | ||
| C02cond.ztst | ||
| C03traps.ztst | ||
| C04funcdef.ztst | ||
| C05debug.ztst | ||
| comptest | ||
| D01prompt.ztst | ||
| D02glob.ztst | ||
| D03procsubst.ztst | ||
| D04parameter.ztst | ||
| D05array.ztst | ||
| D06subscript.ztst | ||
| D07multibyte.ztst | ||
| D08cmdsubst.ztst | ||
| D09brace.ztst | ||
| E01options.ztst | ||
| E02xtrace.ztst | ||
| list-XFails | ||
| Makefile.in | ||
| P01privileged.ztst | ||
| README | ||
| runtests.zsh | ||
| V01zmodload.ztst | ||
| V02zregexparse.ztst | ||
| V03mathfunc.ztst | ||
| V04features.ztst | ||
| V05styles.ztst | ||
| V06parameter.ztst | ||
| V07pcre.ztst | ||
| V08zpty.ztst | ||
| V09datetime.ztst | ||
| V10private.ztst | ||
| V11db_gdbm.ztst | ||
| V12zparseopts.ztst | ||
| W01history.ztst | ||
| W02jobs.ztst | ||
| X02zlevi.ztst | ||
| X03zlebindkey.ztst | ||
| X04zlehighlight.ztst | ||
| Y01completion.ztst | ||
| Y02compmatch.ztst | ||
| Y03arguments.ztst | ||
| ztst.zsh | ||
There are now different sections, expressed by the first letter in the scripts names: A: basic command parsing and execution B: builtins C: shell commands with special syntax D: substititution E: options P: privileged (needs super-user privileges) V: modules W: builtin interactive commands and constructs X: line editing Y: completion Z: separate systems and user contributions You will need to run these by using `make test' in the Test subdirectory of the build area for your system (which may or may not be the same as the Test subdirectory of the source tree), or the directory above. You can get more information about the tests being performed with ZTST_verbose=1 make check (`test' is equivalent to `check') or change 1 to 2 for even more detail. Individual or groups of tests can be performed with make TESTNUM=C02 check or make TESTNUM=C check to perform just the test beginning C02, or all tests beginning C, respectively. Instructions on how to write tests are given in B01cd.ztst, which acts as a model.