aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/trap.h
Commit message (Collapse)AuthorAgeFilesLines
* sh: Keep ignored SIGINT/SIGQUIT after set in a background jobJilles Tjoelker2020-08-281-0/+1
| | | | | | | | | | | | | | | | | | If job control is not enabled, a background job (... &) ignores SIGINT and SIGQUIT, but this can be reverted using the trap builtin in the same shell environment. Using the set builtin to change options would also revert SIGINT and SIGQUIT to their previous dispositions. This broke due to r317298. Calling setsignal() reverts the effect of ignoresig(). Reported by: bdrewery MFC after: 1 week Notes: svn path=/head/; revision=364919
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* sh: Simplify setinteractive().Jilles Tjoelker2017-04-221-1/+1
| | | | | | | setsignal() does nothing if the signal disposition is already set correctly. Notes: svn path=/head/; revision=317298
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* sh: Move some code from onint() to onsig(), making onint() noreturn.Jilles Tjoelker2014-12-211-1/+0
| | | | | | | | As a result, the INTON macro which is used many times generates fewer bytes of code. Notes: svn path=/head/; revision=276038
* sh: Remove SIGWINCH handler and just check for resize before every read.Jilles Tjoelker2014-01-141-1/+0
| | | | | | | | | | | | | | | | The SIGWINCH handler triggers breakage in libedit which is hard to fix; see PR bin/169773. Also, window size changes while a program is in foreground (and it rather than sh will receive SIGWINCH) will now be picked up automatically. Downside: it is now certain that a resize is only processed after pressing <Enter>. If libedit is fixed, sh will most likely have to be changed also. PR: bin/180146 Notes: svn path=/head/; revision=260654
* sh: Fix race condition with signals and wait or set -T.Jilles Tjoelker2013-09-021-0/+1
| | | | | | | | | | | | | The change in r238888 was incomplete. It was still possible for a trapped signal to arrive before the shell went to sleep (sigsuspend()) because a check was missing or because the signal arrived before in_waitcmd was set. On SMP, this bug sometimes caused the builtins/wait4.0 test to take 1 second to execute; it then might or might not fail. On UP, the test almost always failed. Notes: svn path=/head/; revision=255157
* sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig.Jilles Tjoelker2013-02-231-1/+1
| | | | Notes: svn path=/head/; revision=247206
* sh: Fix EINTR race condition in "wait" and "set -T" using sigsuspend().Jilles Tjoelker2012-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | When waiting for child processes using "wait" or if "set -T" is in effect, a signal interrupts the wait. Make sure there is no window where the signal handler may be invoked (setting a flag) just before going to sleep. There is a similar race condition in the shell language, but scripts can avoid it by exiting from the trap handler or enforcing synchronization using a fifo. If SIGCHLD is not trapped, a signal handler must be installed for it. Only install this handler for the duration of the wait to avoid triggering unexpected [EINTR] errors elsewhere. Note that for some reason only SIGINT and SIGQUIT interrupt a "wait" command. This remains the case. Notes: svn path=/head/; revision=238888
* sh: Fix duplicate prototypes for builtins.Jilles Tjoelker2011-06-131-1/+0
| | | | | | | | | Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers. Notes: svn path=/head/; revision=223060
* sh: Make exit without parameters from EXIT trap POSIX-compliant.Jilles Tjoelker2011-01-081-0/+1
| | | | | | | | | | It should use the original exit status, just like falling off the end of the trap handler. Outside an EXIT trap, 'exit' is still equivalent to 'exit $?'. Notes: svn path=/head/; revision=217175
* sh: Add some __dead2 to indicate functions that do not return.Jilles Tjoelker2009-12-241-1/+1
| | | | Notes: svn path=/head/; revision=200967
* Don't skip forking for an external command if any traps are active.Jilles Tjoelker2009-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | Example: sh -c '(trap "echo trapped" EXIT; sleep 3)' now correctly prints "trapped". With this check, it is no longer necessary to check for -T explicitly in that case. This is a useful bugfix by itself and also important because I plan to skip forking more often. PR: bin/113860 (part of) PR: bin/74404 (part of) Reviewed by: stefanf Approved by: ed (mentor) Notes: svn path=/head/; revision=194127
* Remove clause 3 from the UCB licenses.Mark Murray2004-04-061-4/+0
| | | | | | | OK'ed by: imp, core Notes: svn path=/head/; revision=127958
* Avoid calling el_resize() from a signal handler, even though libeditTim J. Robbins2002-07-241-0/+1
| | | | | | | | | | itself does that if you set EL_SIGNAL. Instead, set a flag and check it before calling el_gets(). This is safer, but slower to respond to changes. Pointed out by: mp Notes: svn path=/head/; revision=100588
* o __P has been reovedWarner Losh2002-02-021-8/+8
| | | | | | | | | | | | | | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o Change int foo() { ... to int foo(void) { ... Notes: svn path=/head/; revision=90111
* $Id$ -> $FreeBSD$Peter Wemm1999-08-271-1/+1
| | | | Notes: svn path=/head/; revision=50471
* Do not exit on SIGINT in non-interactive shells, fixes PR 1206,Martin Cracauer1998-08-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | i.e. this makes emacs usable from system(3). Programs called from shellscripts are now required to exit with proper signal status. That means, they have to kill themself. Exiting with faked numerical exit code is not sufficient. Exit with proper signal status if script exits on signal. Make the wait builtin interruptable, both with and without traps set. Use volatile sig_atomic_t where (and only where) appropriate. (Almost) fix printing of newlines on SIGINT. Make traps setable from trap handlers. This is needed for shellscripts that catch SIGINT for cleanup work but intend to exit on it, hance have to kill themself from a trap handler. I.e. mkdep. While I'm at it, make it -Wall clean. -Wall is not enabled in Makefile, since vararg warnx() macro calls in usr.bin/printf/printf.c are not -Wall-able. PR: 1206 Obtained from: Basic SIGINT fix from Bruce Evans Notes: svn path=/head/; revision=38521
* Fixed some type and value mismatches. setsignal() returned a boguslyBruce Evans1997-11-101-2/+2
| | | | | | | | | cast value that was always ignored. Rev.1.9 of trap.c made this more bogus by returning a semantically different value after calling siginterrupt(). Avoid these problems by not returning a value. Notes: svn path=/head/; revision=31098
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=22988
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Merge in NetBSD mods and -Wall cleaning.Steve Price1996-12-141-4/+4
| | | | | | | Obtained from: NetBSD, me Notes: svn path=/head/; revision=20425
* Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is aPeter Wemm1996-09-011-17/+10
| | | | | | | | | | | | | | | | | merge of parallel duplicate work by Steve Price and myself. :-] There are some changes to the build that are my fault... mkinit.c was trying (poorly) to duplicate some of the work that make(1) is designed to do. The Makefile hackery is my fault too, the depend list was incomplete because of some explicit OBJS+= entries, so mkdep wasn't picking up their source file #includes. This closes a pile of /bin/sh PR's, but not all of them.. Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter Notes: svn path=/head/; revision=17987
* Added $Id$David Greenman1994-09-241-0/+1
| | | | Notes: svn path=/head/; revision=3044
* BSD 4.4 Lite bin SourcesRodney W. Grimes1994-05-261-0/+55
Notes: svn path=/head/; revision=1556