summary refs log tree commit diff
path: root/Src/jobs.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* 35849: close fd's from process substitution after forkPeter Stephenson2015-07-231-4/+6
| | | | Leaving these hanging in parent could cause deadlock: test added.
* 35032: Handle SIGCONT for process better.Peter Stephenson2015-05-051-1/+3
| | | | Update job status as well as process status.
* 34120: compctl, jobs: Check contents instead of arrayMikael Magnusson2015-01-061-1/+1
| | | | | | text is an array in the struct, and can never be null. Found by Coverity (Issue 1255780).
* 33992: do not attempt attachtty() for process group zero (which is possible ↵Barton E. Schaefer2014-12-181-2/+5
| | | | in a linux pid namespace)
* 33982: minimal support for pid namespaces by recognizing that GETPGRP() may ↵Chirantan Ekbote2014-12-161-1/+1
| | | | return 0
* 33876: etc.: Separate errors and keyboards interruptsPeter Stephenson2014-12-111-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* unposted: quash compiler warningOliver Kiddle2014-10-311-0/+2
|
* 33562: Fix thinko in previous commitMikael Magnusson2014-10-271-1/+3
|
* 33561: The time builtin forgot to unmetafy TIMEFMTMikael Magnusson2014-10-271-1/+1
|
* 33531 with additions: retain status of exited background jobs.Peter Stephenson2014-10-261-21/+117
| | | | | | | | 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.
* 33354: when backgrounding a pipeline, close all pipe descriptors in the parentBarton E. Schaefer2014-10-041-1/+3
| | | | Add test for both this and 33345+33346
* 33042: $? and $pipestatus report 128+signal number for stopped jobsBarton E. Schaefer2014-08-221-5/+10
|
* 32624: use correct scaling factor (clock ticks) for timesPeter Stephenson2014-05-291-15/+17
|
* 32178: fix another acquire_pgrp() infinite loopBarton E. Schaefer2013-12-251-0/+4
|
* 32176: plug additional deadlock-inducing pipe descriptor leaksPeter Stephenson2013-12-211-13/+25
|
* 31929: Src/jobs.c: fix DPUTS3() test condition from 31906.Barton E. Schaefer2013-10-291-1/+1
|
* 31906: fix race-condition interaction of $pipestatus with job controlBarton E. Schaefer2013-10-261-3/+10
| | | | 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.
* 31885: fix PIPEFAIL when the last command executes in the current shellBarton E. Schaefer2013-10-241-18/+24
|
* 31879 plus misc.: improve $pipestatus handling and add a test for itBarton E. Schaefer2013-10-231-17/+35
|
* users:18023: Add PIPEFAIL optionPeter Stephenson2013-10-061-3/+10
|