Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
kill builtin argument parsing
- X-seq: zsh-workers 38615
- From: Matthew Malcomson <hardenedapple@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: kill builtin argument parsing
- Date: Sun, 5 Jun 2016 17:35:54 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=ROvW009NHbcb4YcufbDqKkrBJ3gqnlggyEWHJjk1s18=; b=PxMpJ0NSwiwZYBE0rok14HmrNy2kbx3DEKCDugL/qB7kzro39GzQmwj9Y4qGnNOhYJ mA6mG1b56Lq00icv0EUzvkQgckTjFDME6kTea2S5+h0aO+b8frLwwrwGHtWbFsYku3R7 H/z6NOZz8Dj6GYfcfvKgCzhDr5sf6dQLEGwUJEAg05sTKWzQrHT/8M9y+axT3CaAMGqL x/Nz2e2ZxbXqU+Q8GWAdwQ6I7FHB6ISy0g8fZxQdLp+FcsM5DMDasj3Y80QVsolLRaNE eiN/CT8nvM+mvFpkLic695P1sycNtXyf7xVf4cOoqMbI88utBFTeI54kV1e6dUAGRb0z NuNw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello there,
I recently mistakenly used arguments for the /bin/kill binary with the
zsh kill builtin and noticed something strange that I think should be
improved.
The command line I used was:
kill -1 -- <any pid>
which ends up killing the current Zsh process.
This is because the pid valid argument check at Src/builtin.c:2572 uses
isanum() that just asserts that all characters in the string are either
'-' or a digit.
When the string "--" is parsed as a digit with atoi() in Src/jobs.c:2572
it returns '0' which is passed to kill(2) syscall.
I'm not sure whether to suggest changing the isanum() function, or the
check in bin_kill() that relies on it.
I would personally change the isanum() function, as a cursory reading of
the two places it's used appear to not require this particular behaviour
(the other place it's used in Src/jobs.c:2193 doesn't appear to have any
negative consequences either way), but the comment above this isanum()
function clearly shows it was a known behaviour, so there may be a
reason I'm missing.
Either way I think the behaviour is surprising enough and possible
enough to be worth changing.
Cheers
MM
Messages sorted by:
Reverse Date,
Date,
Thread,
Author