about summary refs log tree commit diff
path: root/Src/jobs.c
Commit message (Collapse)AuthorAgeFilesLines
* 52622 (tweaked, c.f. 52626): adjust number of columns and drop ↵Oliver Kiddle2024-02-281-6/+9
| | | | right-parenthesis in "kill -L" output
* 52594: support for POSIX real-time signals with kill and trapOliver Kiddle2024-02-281-16/+97
| | | | Also add new -L option to kill for a more verbose listing of signals
* 52365: record state of exited background jobs so as to be visible in TRAPCHLDBart Schaefer2023-12-091-0/+19
|
* 52326, 52372: add -q option to kill for sigqueueOliver Kiddle2023-12-051-2/+34
|
* 51977: PIPEFAIL interaction with ERREXIT / ERRRETURNPeter Stephenson2023-07-201-5/+11
| | | | | | Ensure the list-level error handling code is executed if we detect pipe failure for a foreground job. Add tests.
* 51769: fix compilation when HAVE_GETRUSAGE is not definedOliver Kiddle2023-05-211-1/+1
| | | | Also silence compiler warning when HAVE_SETUPTERM is not defined.
* 51604: %M in TIMEFMT should report in kilobytesJun-ichi Takimoto2023-03-301-7/+7
|
* 51602: Handle SIGIOT as an alias to SIGABRT if they are the same signal numberMikael Magnusson2023-03-281-0/+5
|
* 51404: Nullify filelist after deleting (fix segfault)Bart Schaefer2023-02-121-2/+6
|
* 50922: fix additional cases of signals for current shell jobs on the right ↵Bart Schaefer2022-11-091-6/+0
| | | | | | | | | of a pipeline. Backs out part of 188c5cd5 (workers/50874). With this change, after a new subshell is forked upon suspend of the right side of a pipeline, the previous foreground subjob is resumed first and the new subshell remains stopped until that job finishes.
* 50874: fix handling of tty signals for jobs in the current shell when ↵Bart Schaefer2022-11-061-11/+13
| | | | | | | | | | | | | | | | | | | | | | | waiting for the right side of a pipeline. Reverts 15bf8ace (workers/50134). Thanks to Jun T. for debugging assistance. Issues came down to two things: 1. update_job() may be called on a process group leader even when a signal was NOT sent to any process in that process group. This caused jobs to be resumed or backgrounded incorrectly or in the wrong order. 2. When there is a current-shell complex command (in braces) on the right side of a pipeline, external processes within it have their own process groups, but a tty signal sent to such a process should be treated as if received by the whole complex command. This fixes: * Suspend/resume of a foreground pipeline within a shell function * Interrupt or suspend/resume of processes in a pipeline ending in { ... } * Interrupt of such a pipeline after exit of the last process in { ... } These affected interactive shells only (MONITOR set plus tty signals).
* 50379/50380: fix off-by-one side-effect of workers/49906 that broke $(jobs -l)Bart Schaefer2022-06-211-1/+1
|
* 50342: fix test added by 50306Jun-ichi Takimoto2022-06-091-0/+2
|
* 50306: fix wait for child that was stopped/continuedJun-ichi Takimoto2022-06-031-2/+18
| | | | do not call addbgstatus() when child is stopped/continued
* 50149: Remove all remaining =(...) files at shell exitBart Schaefer2022-04-301-0/+12
|
* 50134: Tweak process group handling to prevent unkillable pipelinesBart Schaefer2022-04-291-1/+4
| | | | | | In some cases the process group leader of the forked-left side of a pipe needs to be set to the pipe process PID rather than to the group leader PID returned by entersubsh().
* 49906 (Bart), 49911: Fixes to querying jobs in subshell.Peter Stephenson2022-03-301-0/+20
| | | | | | | | Don't attempt to query invalid job off end of table, resulting in crashes from $jobtstates. If background task started in subshell, look at tatsks within subshell instead of main shell. Document and add test.
* 49783: Consistently use old job table in parameter modulePeter Stephenson2022-03-011-9/+25
|
* 33465: use prctl() for "jobs -Z" where availableHan Pingtian2021-05-151-0/+7
| | | | Bart apologizes for waiting 7 years to apply this change.
* 46060: Fix spurious actions on exit status 130 or 131.Peter Stephenson2020-06-181-4/+7
| | | | Ensure process has taken a signal before looking for SIGINT or SIGQUIT.
* users/24710: Fix job control problem with sudo.Peter Stephenson2020-02-271-4/+10
| | | | | | | 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.
* 45453: builtins: kill: Do not signal current process group when pid is emptyChris Down2020-02-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 45004: Fix typos in commentsMartijn Dekker2019-12-111-1/+1
|
* 44864: Avoid inifinite loop in tty init.Peter Stephenson2019-10-281-2/+16
| | | | | | | 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.
* 44290: job number exceeding int range and wrapping to a negative number ↵Oliver Kiddle2019-05-141-1/+1
| | | | crashed the shell
* 43945 (tweaked to remove test failure, noted in test):Martijn Dekker2018-12-301-10/+13
| | | | | Fix exit statuses from wait for POSIX_BUILTINS mode. Also add tests.
* 43589: Further improved subjob reporting.Peter Stephenson2018-10-031-9/+5
| | | | | Show subjob status instead of user-visible superjob any time the subjob still has associated processes.
* 43570: Start documenting jobs.c, in particular superjobs.Daniel Shahaf2018-09-281-3/+24
|
* 43564: improve job control report about stopped subjobPeter Stephenson2018-09-261-5/+37
|
* 43543: Further improvements to fg/bg of superjob/subjob.Peter Stephenson2018-09-251-22/+25
| | | | | | | Attempt to keep STAT_STOPPED correct for superjob, rendering additional "stopped = 1" unnecessary. Wait for subjob before superjob.
* 43535: Fixes for bg / fg handling of superjobs.Peter Stephenson2018-09-241-16/+27
| | | | | | | | | | | 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.
* 43464: Another attachtty() fix.Peter Stephenson2018-09-161-0/+10
| | | | | | | | | 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.
* 43446: More entersubsh() / addproc() wiring.Peter Stephenson2018-09-121-4/+10
| | | | | Fix additional races by passing back use of list_pipe_job from subshell.
* 43409: Fix process group setting in main shell.Peter Stephenson2018-09-071-4/+9
| | | | | | | | | 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.
* 42793: Always define FDT_PROC_SUBST even if not needed.Peter Stephenson2018-05-171-5/+1
| | | | This avoids proliferating #ifdef's.
* 42453: Fix race in look up of status for wait.Peter Stephenson2018-03-121-2/+5
| | | | | | 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.
* 42362: protect REPORTTIME logic from bad statusPeter Stephenson2018-02-171-0/+3
|
* add millisecond and microsecond options to TIMEFMT variabledana2017-12-141-0/+34
|
* 41688: builtin wait for all jobs should ignore STAT_NOPRINTPeter Stephenson2017-09-131-1/+2
|
* Delay processing "disown" for superjob.Peter Stephenson2017-07-041-0/+8
| | | | | | | 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.
* 41386: when backgrounding a STAT_CURSH job, remove the flag.Peter Stephenson2017-07-021-1/+3
| | | | | This typical applies to a STAT_SUPERJOB. It prevents it from getting copied interrupts as a foreground process.
* 39359: Fix remaining race with orphaned subjob.Peter Stephenson2016-09-161-1/+2
| | | | | | 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.
* 39331: Reparent subjob on fork with exited superjob.Peter Stephenson2016-09-161-2/+9
| | | | | | | | | | | 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.
* 38923: zwaitjob() continues waiting for children that may have ignored the ↵Barton E. Schaefer2016-07-231-1/+8
| | | | interrupt signal, even if the current shell has been interrupted.
* users/21632: Use of REPORTMEMORY variablePeter Stephenson2016-06-131-14/+39
| | | | | | 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.
* 38622: consistent handling of "--" in "kill" builtinBarton E. Schaefer2016-06-051-0/+4
|
* 37868: add 'static' to file local variablesJun-ichi Takimoto2016-02-031-3/+3
|
* 36180: avoid infinite job stop/continue loop on "wait PID" for a background jobBarton E. Schaefer2015-08-151-1/+8
|
* 36104: change order of child_block() and dont_queue_signals() to resolve yet ↵Barton E. Schaefer2015-08-111-2/+2
| | | | another race condition
* 35929: protect FDT_PROC_SUBST by #ifdefJun-ichi Takimoto2015-08-091-2/+5
|