| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
If we use kill to test for continued existence of a process group,
we should check on failure that the error is ESRCH, as EPERM
indicates the group still has memebers but running privileged
so should be left alone.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
If we can't grab the terminal in interactive mode, give
up after 100 goes. This is a completely arbitrary choice;
we simply don't know what in the system could change the
result of looping further.
|
|
|
|
| |
crashed the shell
|
|
|
|
|
| |
Fix exit statuses from wait for POSIX_BUILTINS mode.
Also add tests.
|
|
|
|
|
| |
Show subjob status instead of user-visible superjob any time
the subjob still has associated processes.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Attempt to keep STAT_STOPPED correct for superjob, rendering additional
"stopped = 1" unnecessary.
Wait for subjob before superjob.
|
|
|
|
|
|
|
|
|
|
|
| |
Be more consistent about marking both superjob and subjob as
running when sending SIGCONT.
Send SIGCONT to superjob / subjob combination any time it is put
in foreground, even if thought running, since subjob may invisibly
have suspended.
When waiting for superjob, wait for subjob, too.
|
|
|
|
|
|
|
|
|
| |
If list_pipe_job triggered more than once we need to know
the most recent process group leader, so record that
both if the attach happened in the main shell on in
entersubsh().
Also don't pass back proocess group for ESUB_ASYNC subshells.
|
|
|
|
|
| |
Fix additional races by passing back use of list_pipe_job
from subshell.
|
|
|
|
|
|
|
|
|
| |
A newly forked subshell now reports back the process group it
will be using for the main shell to record.
This prevents an error where the shell incorrectly thought an
exiting process owned the terminal and so grabbed it back,
putting the foreground process into the background.
|
|
|
|
| |
This avoids proliferating #ifdef's.
|
|
|
|
|
|
| |
Background jobs that had just exited could still be in
the table when the process had already finished and the
status was recorded, causing the wrong status to be reported.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This is a job forked from the current shell when a job partly
running from the current shell was suspended. When all associated
processes started from the main shell are finished the job is
continued and at this point the disown can complete.
|
|
|
|
|
| |
This typical applies to a STAT_SUPERJOB. It prevents it from
getting copied interrupts as a foreground process.
|
|
|
|
|
|
| |
When shell is forked to run right hand side of pipieline it should
use its own PID as process group if the left hand side of the
pipeline has already exited.
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes case of
v() { { vim - } always { true } }
ls | v
^Z
fg
Tentative fix: still a race at exit where zsh forked by ^Z
is stopped when restarted.
|
|
|
|
| |
interrupt signal, even if the current shell has been interrupted.
|
|
|
|
|
|
| |
If the child's resisdent set size in megabytes exceeds this, print
out the resource (TIMEFMT) string. Document you need to add memory
usage to this by hand.
|
| |
|
| |
|
| |
|
|
|
|
| |
another race condition
|
| |
|
|
|
|
| |
Leaving these hanging in parent could cause deadlock: test added.
|
|
|
|
| |
Update job status as well as process status.
|
|
|
|
|
|
| |
text is an array in the struct, and can never be null.
Found by Coverity (Issue 1255780).
|
|
|
|
| |
in a linux pid namespace)
|
|
|
|
| |
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Combination of 12 commits from interrupt_abort branch.
Basic strategy is to introduce bits to errflag and to set and
reset them separately.
Remove interrupt status on return to main keymap.
Turn off ERRFLAG_INT for always block.
Restore bit thereafter: we probably need a new variable in order
to allow user interrupts to be reset in the always block.
Add TRY_BLOCK_INTERRUPT
This works the same as TRY_BLOCK_ERROR, but for a SIGINT, too.
Ensure propagation of SIGINT from exited job.
If received by foreground job, shell uses ERRFLAG_INT, not
ERRFLAG_ERROR, to set the new state.
Reset errflag before precmd()
Add always block in _main_completion to fix ZLS_COLORS
Ensures we get the right state of $ZLS_COLORS at the end of _main_complete
even if there's an interrupt. However, the "right state" is a bit messy
as it depends on styles.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Add linked list of unwaited-for background jobs.
Truncate at value of _SC_CHILD_MAX discarding oldest.
Remove old lastpid_status mechanism for latest exited process only.
Slightly tighten safety of permanently allocated linked lists so
that this doesn't compromise signal handling.
|
|
|
|
| |
Add test for both this and 33345+33346
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
printjob() should not reference oldjobtab for job numbers unless it is being called from bin_fg(). printjob() also must not attempt to update pipestats when called from bin_fg(). acquire_pgrp() should not loop infintely if the shell is not interactive. Update the $pipestatus stress test so that it also exercises the oldjobtab repair.
|
| |
|
| |
|
| |
|