1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-25 05:27:12 +02:00
Commit Graph

101 Commits

Author SHA1 Message Date
Peter Stephenson
14ea665a90 users/24710: Fix job control problem with sudo.
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.
2020-02-27 20:42:16 +00:00
Daniel Shahaf
8bc4400762 45058: internal: Add symbolic names to possible values of zexit()'s "from_where" parameter. No functional change. 2019-12-17 05:12:36 +00:00
Peter Stephenson
95211f87ed 44259: Ensure we can set signals to default even if ignored.
Previously the shell didn't take account of signals marked as

ignored on entry, which was inconsistent with other behaviour.
2019-05-13 09:55:01 +01:00
Peter Stephenson
0a20f4e5a6 43535: Fixes for bg / fg handling of superjobs.
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.
2018-09-24 21:32:40 +01:00
Peter Stephenson
551ff84272 43464: Another attachtty() fix.
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.
2018-09-16 19:13:38 +01:00
Peter Stephenson
07ad7fd970 Fix windowsize when reattaching to terminal on process exit 2018-09-12 09:49:14 +01:00
Eitan Adler
f311619e30 433029: Testing signal return type is no longer needed 2018-06-18 10:18:29 +01:00
Peter Stephenson
449f13a467 42234: Stephane: don't kill a process if not running.
This could happen when kiiling a job.  The processs might be reused.
2018-05-14 16:47:29 +01:00
Peter Stephenson
9ad9c5cda1 42705: Another safety fix for pgrp reclaiming.
Only do this if killpg(dead_pid, 0) returns -1, indicating
the pgprp doesn't exist any more, else there is a race
if other proceses have started using it.
2018-04-23 15:11:34 +01:00
Peter Stephenson
0f29b5148e 42686: Fix previous pgrp patch.
We shouldn't do any fix ups unless the process has actually
exited.
2018-04-19 13:58:10 +01:00
Peter Stephenson
3c74891fcd 42630: Improve process group handling in pipelines.
If process group leader exits, allow a newly forked process to become
process leader.  If a foreground job, reattach the shell to the
terminal until that happens.

Unblock signals when reading output for command subsitution so that
we can do this reattaching immediately.
2018-04-17 17:14:20 +01:00
Peter Stephenson
97d4bdbc7e 41590 modified as 41595: make ERR_RETURN more logical.
It now operates separately at each function depth.

To keep ERR_EXIT global, make the noerrexit variable usd bit flags.

Extend tests.
2017-08-24 19:46:20 +01:00
Peter Stephenson
d7110d8f01 41012: Fix premature exit from nested function in EXIT trap.
Also add check so we don't delay an exit if we were already in
an EXIT trap for the main shell, as we should in that case leave
immediately.
2017-04-27 18:56:18 +01:00
Barton E. Schaefer
12d950ba0c 40624: conditionally handle WIFCONTINUED to properly set SP_RUNNING process status 2017-02-23 16:19:07 -08:00
Peter Stephenson
f90a0447aa 40353 with tweaks to whence -v: extend directory cache use.
Now used for all autoloaded functions after load, including those
where the file was found along fpath, reducing duplication of
directory names.
2017-01-16 10:31:56 +00:00
Peter Stephenson
178e62dbfe 40342: Add directory name cache for autoload file paths.
This renders "autoload /blah/blah/*" as efficient as use of
fpath.
2017-01-12 20:56:20 +00:00
Barton E. Schaefer
4abbb4b473 39548: DEBUG for queueing_enabled 2016-10-03 09:37:10 -07:00
Peter Stephenson
e35dcae40f 39436: Pass on status of SIGINT better.
Set lastval to 128 + SIGINT on interrupt.

Don't execute builtin if already interrupted at that point.
2016-09-25 19:18:43 +01:00
Peter Stephenson
327f3dd3ad 39359: Fix remaining race with orphaned subjob.
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.
2016-09-16 17:23:12 +01:00
Peter Stephenson
17fb014dc7 38094: Fix POSIX EXIT traps defined in function.
These aren't local, so set the local level to 0; else they can get
overridden incorrectly.
2016-03-07 09:42:21 +00:00
Peter Stephenson
c55d855171 38024: Improve POSIX and native EXIT traps compatibility.
Allow a nested function trap to leave save and restore a POSIX
trap.

Still fails if the POSIX trap was defined in a function.
2016-02-25 14:20:26 +00:00
Peter Stephenson
ab74c86edb 37999: Sticky behaviour of EXIT traps.
They now have POSIX or non-POSIX behaviour based on the setting
of POSIX_TRAPS where the trap was defined, rather than where the
trap would (or would not) be executed.

Tweaks possible.
2016-02-17 10:40:55 +00:00
Barton E. Schaefer
9f5dffa1f3 36393: process queued signals during dotrap() 2015-09-02 19:11:54 -07:00
Barton E. Schaefer
93ca77f8f7 36079: do not allow update_job() and its helpers to run the signal queue while we are processing a job exit. 2015-08-10 12:54:05 -07:00
Peter Stephenson
a07f74fadd Don't rely on implicit value when saving background process status 2015-08-10 16:59:55 +01:00
Barton E. Schaefer
9958684574 36022 fix bug that some loop constructs could not be interrupted, revise signal queueing
There are two underlying ideas here:  (1) Keeping signals queued around
anything that's doing memory management (including push/pop of the heap)
has become crucial.  (2) Anytime the shell is going to run a command, be
it buitin or external, it must be both safe and necessary to process any
queued signals, so that the apparent order of signal arrival and command
execution is preserved.
2015-08-09 16:13:52 -07:00
Peter Stephenson
cfd91eac07 Rearrange context saving.
Variables are now associated with the module that declares them, being
initialised and saved/restored there.  However, as many variables are
used for communication between modules, many of them are set in multiple
places, so the assignment is ambiguous.
2015-01-09 21:33:39 +00:00
Peter Stephenson
d067ebcacd 33876: etc.: Separate errors and keyboards interrupts
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.
2014-12-11 09:41:17 +00:00
Peter Stephenson
b4f7ccecd9 33531 with additions: retain status of exited background jobs.
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.
2014-10-26 17:47:42 +00:00
Barton E. Schaefer
32473f59a3 Merge branch 'master' of git://git.code.sf.net/p/zsh/code
Conflicts:
	ChangeLog
2014-09-29 17:52:33 -07:00
Peter Stephenson
cf6b0f5663 33285: apply function definition redirections at execution 2014-09-29 21:02:59 +01:00
Barton E. Schaefer
60e31a45b0 33268: interactive shells treat SIGPIPE like SIGHUP if and only if SHTTY is disconnected 2014-09-29 08:59:31 -07:00
Nikolas Garofil
4f4d2b8247 32737, 32736 (32741), 32735, 32734, 32733, 32732 (32739): Strict compilation
fixes

	Src/utils.c: properly ifdef declarations
	Src/zsh_system.h: memmove() should return its dest argument
	Src/signals.c: define ret before use
	Src/mem.c: remove unused pointers
	Src/prototypes.h: use size_t in bcopy()
	Src/compat.c: fix const declaration inconsistency
2014-06-07 13:48:40 -07:00
Peter Stephenson
a06cd1766a 32479: POSIXTRAPS and implicit return values.
With POSIXTRAPS never propagate implicit return value.
In any case if not forcing a return value don't use lastval
from within the trap, use the one from the surrounding code.
2014-03-14 12:52:41 +00:00
Peter Stephenson
375115c7df unposted: updates for 4.0.2-test-1.
Update references to 4.0.2 to 4.0.3.
Additional mod_export declarations.
Additions to .distfiles.
2013-11-06 19:25:07 +00:00
Peter Stephenson
4b86cc48f7 30726: make shell options passed to emulate stick along with the emulation 2012-10-11 20:14:01 +00:00
Bart Schaefer
748bd73d88 unposted: cross-reference zmodload from the modules intro doc.
29769: follow-up 29677 to handle the case where thisjob == -1.
2011-09-25 18:09:13 +00:00
Bart Schaefer
516ea294b8 29677: Do not allow external processes in a pipeline to become suspended
when the end of the pipe is controlled by a builtin in the current shell
which cannot itself become suspended.
2011-08-14 18:34:27 +00:00
Peter Stephenson
a3ae9f5d12 29643: set incompfunc to zero when executing hook or trap function 2011-08-04 08:30:50 +00:00
Bart Schaefer
98b29d02ca 29481: always return a matching job in findproc() but scan the whole list
to prefer running jobs
2011-06-15 15:38:14 +00:00
Peter Stephenson
3b6b4982b9 28258: fix undefined variable in traps 2010-09-14 12:52:31 +00:00
Peter Stephenson
ade705cf5b 28253: document -h argument to atribute commands 2010-09-12 18:56:40 +00:00
Peter Stephenson
c7ff1b79dd 28179, users/15314, users/15310, users/15200:
various job and process control fixes
2010-08-22 20:08:57 +00:00
Peter Stephenson
09960dc5b9 27951: Add $ZSH_EVAL_CONTEXT and $zsh_eval_contxt 2010-05-12 10:06:59 +00:00
Peter Stephenson
3206b8a2ea 27442 plus tweak: wait returns status for $! even if exited 2009-12-02 09:46:12 +00:00
Bart Schaefer
bda90c969f 27159: restore pre-23067 behavior of SIGINT outside a "wait", so that
foreground jobs that handle or ignore interrupts are not orphaned.
2009-07-20 04:38:56 +00:00
Peter Stephenson
73be7ee553 27106: reset status on command that expands to empty
27122: add POSIX_JOBS option
2009-07-10 11:08:39 +00:00
Peter Stephenson
c7d8b0dfb8 26546, 26556: sticky emulation for functions defined in emulate ... -c ...
environments, plus documentation
2009-02-11 20:42:15 +00:00
Peter Stephenson
e3fd25b181 25775: fix logical problem with function line numbering inside eval-style traps 2008-09-29 21:46:58 +00:00
Peter Stephenson
b2d08a2155 25744: dynamic named directories and further doshfunc() simplification 2008-09-26 09:11:27 +00:00