The NetBSD Project

CVS log for src/bin/sh/trap.c

[BACK] Up to [cvs.NetBSD.org] / src / bin / sh

Request diff between arbitrary revisions


Default branch: MAIN
Current tag: MAIN


Revision 1.56 / (download) - annotate - [select for diffs], Wed Nov 10 15:26:34 2021 UTC (2 years, 4 months ago) by kre
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, HEAD
Changes since 1.55: +8 -2 lines
Diff to previous 1.55 (colored)


DEBUG mode changes only.   NFC (NC) for any normally compiled shell.

Mostly adding DEBUG mode tracing (when appropriate verbose tracing
is enabled generally) whenever a shell (including sushell) process
exits, so shells that the tracing should indicate why ehslls that
vanish did that.

Note for future investigators: if the relevant tracing is enabled,
and a (sub-)shell still simply seems to have vanished without trace,
the likely cause is that it was killed by a signal - and of those,
the most common that occurs is SIGPIPE.

Revision 1.55 / (download) - annotate - [select for diffs], Thu Aug 20 23:09:56 2020 UTC (3 years, 7 months ago) by kre
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.54: +23 -11 lines
Diff to previous 1.54 (colored)


Be less conservative about when we do clear_traps() when we have
traps_invalid (that is, when we actually nuke the parent shell's
caught traps in a subshell).  This allows more reasonable use of
"trap -p" (and similar) in subshells than existed before (and in
particular, that command can be in a function now - there can also
be several related commands like
	traps=$(trap -p INT; trap -p QUIT; trap -p HUP)
A side effect of all of this is that
	(eval "$(trap -p)"; ...)
now allows copying caught traps into a subshell environment, if desired.

Also att the ksh93 variant (the one not picked by POSIX as it isn't
generally as useful) of "trap -p" (but call it "trap -P" which extracts
just the trap action for named signals (giving more than one is usually
undesirable).   This allows
	eval "$(trap -P INT)"
to run the action for SIGINT traps, without needing to attempt to parse
the "trap -p" output.

Revision 1.54 / (download) - annotate - [select for diffs], Thu Aug 20 16:15:50 2020 UTC (3 years, 7 months ago) by kre
Branch: MAIN
Changes since 1.53: +7 -7 lines
Diff to previous 1.53 (colored)


Whitespace.   NFCI.

Revision 1.53 / (download) - annotate - [select for diffs], Mon Dec 9 00:14:30 2019 UTC (4 years, 3 months ago) by kre
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, is-mlppp-base, is-mlppp
Changes since 1.52: +8 -2 lines
Diff to previous 1.52 (colored)

PR bin/54743

If a builtin command or function is the final command intended to be
executed, and is interrupted by a caught signal, the trap handler for
that signal was not executed - the shell simply exited (an exit trap
handler would still have been run - if there was one the handler
for the signal may have been invoked during the execution of the
exit trap handler, which, if it happened, is incorrect sequencing).

Now, if we're exiting, and there are pending signals, run their handlers
just before running the EXIT trap handler, if any.

There are almost certainly plenty more issues with traps that need
solving.   Later,

XXX pullup -9

(-8 is too different in this area, and this problem suitably obscure,
that we won't bother)     (the -7 sh is simply obsolete).

Revision 1.52 / (download) - annotate - [select for diffs], Thu Apr 25 03:54:10 2019 UTC (4 years, 11 months ago) by kre
Branch: MAIN
CVS Tags: phil-wifi-20191119, phil-wifi-20190609, netbsd-9-base, netbsd-9-0-RC1
Branch point for: netbsd-9
Changes since 1.51: +72 -12 lines
Diff to previous 1.51 (colored)

Better interactive SIGINT handling (when a trap is set), and other
cleanups to the trap code.   No longer silently ignore attempts to
do anything other than set SIGKILL or SIGSTOP to the default ('-")
state.   Don't include those in trap or trap -p output (the former
because they cannot be other than in default state, so simply aren't
included, the latter because it is pointless) but do list them
when requested with trap -p SIG.

Interactive mode SIGINT traps are now run ASAP, rather than after
a command has been entered (so the sequence ^C \n is no longer needed
to generate one).   Further, when trapped, in interactive mode,
while waiting for a user command, a SIGINT acts (aside from the
trap being run) just like when not trapped, aborts the command being
entered (rather than leaving it, which it did when libedit was in use)
prints a new prompt, and starts again (which is what should happen.)

Traps other than SIGINT (which has always been handled special in
interactive mode) are unaffected by this change, as are SIGINT traps
in non-interactive shells.    Or that is the intent anyway.

Fix an in_dotrap ref count bug (was never being decremented... that
was inserted in a place never executed) (relatively harmless) and
add/improve some trap/signal related DEBUG mode tracing.

Revision 1.51 / (download) - annotate - [select for diffs], Fri Jan 18 06:28:09 2019 UTC (5 years, 2 months ago) by kre
Branch: MAIN
CVS Tags: pgoyette-compat-20190127, pgoyette-compat-20190118
Changes since 1.50: +6 -6 lines
Diff to previous 1.50 (colored)

Finish (hopefully) the second half of 1.47 ... make sure
that when traps are marked as invalid, we never use them
for anything except output from the trap command.

Fixes issues where sub-shells of shells which use traps
(eg: to trap SIGPIPE) can end up looping forever if the
signal occurs in a sub-shell (where the trap is supposed
to be reset to its default).   Reported, and mostly
analyzed by Martijn Dekker.

Revision 1.50 / (download) - annotate - [select for diffs], Wed Dec 12 20:22:43 2018 UTC (5 years, 3 months ago) by kre
Branch: MAIN
CVS Tags: pgoyette-compat-1226
Changes since 1.49: +63 -4 lines
Diff to previous 1.49 (colored)

Reverse a decision made when the printsignals() routines from
kill and sh were merged so that the shell (for trap -l) and
kill (for kill -l) can use the same routine, and site that function
in the shell, rather than in kill (use the code that is in kill as
the basis for that routine).   This allows access to sh internals,
and in particular to the posix option, so the builtin kill can
operate in posix mode where the standard requires just a single
character (space of newline) between successive signal names (and
we prefer nicely aligned columns instead)..

In a SMALL shell, use the ancient sh printsignals routine instead,
it is smaller (and very much dumber).

/bin/kill still uses the routine that is in its source, and is
not posix compliant.   A task for some other day...

Revision 1.49 / (download) - annotate - [select for diffs], Wed Dec 5 22:25:38 2018 UTC (5 years, 3 months ago) by kre
Branch: MAIN
Changes since 1.48: +2 -0 lines
Diff to previous 1.48 (colored)


evert previous, linux build problem confirmed fixed by
update to mkinit.sh (to 1.10).

Or more correctly, revert & fix - turns out that there was an off by one
(failure to adjust for other changes -- in a value printed by debug mode
trace output).

NFC.

Revision 1.48 / (download) - annotate - [select for diffs], Wed Dec 5 03:14:28 2018 UTC (5 years, 3 months ago) by kre
Branch: MAIN
Changes since 1.47: +2 -4 lines
Diff to previous 1.47 (colored)


NFC (except that it should, I am guessing, fix compilation on
some versions of liux) - DEBUG mode change:  Delete a (relatively new)
trace point (temporarily anyway) which mkinit (a script run using the
host's /bin/sh) apparently cannot handle correctly on (some release of)
linux (it is fine with the NetBSD shell).

I don't know which linux version has a shell with this problem
(or whether it is a mkinit issue that only works by fluke on NetBSD)

Problem reported by gson@

Revision 1.47 / (download) - annotate - [select for diffs], Mon Dec 3 06:43:19 2018 UTC (5 years, 3 months ago) by kre
Branch: MAIN
Changes since 1.46: +226 -58 lines
Diff to previous 1.46 (colored)

Cleanup traps a bit - attempt to handle weird uses in traps, such
as traps that issue break/continue/return to cause the loop/function
executing when the trap occurred to break/continue/return, and
generating the correct exit code from the shell including when a
signal is caught, but the trap handler for it exits.

All that from FreeBSD.

Also make
	T=$(trap)
work as it is supposed to (also trap -p).

For now this is handled by the same technique as $(jobs) - rather
than clearing the traps in subshells, just mark them invalid, and
then whenever they're invalid, clear them before executing anything
other than the special blessed "trap" command.   Eventually we will
handle these using non-subshell command substitution instead (not
creating a subshell environ when the commands in a command-sub alter
nothing in the environment).

Revision 1.46 / (download) - annotate - [select for diffs], Sun Oct 28 18:26:52 2018 UTC (5 years, 5 months ago) by kre
Branch: MAIN
CVS Tags: pgoyette-compat-1126
Changes since 1.45: +20 -20 lines
Diff to previous 1.45 (colored)


Switch from using two printsignals() functions, one in trap.c
and one in (the included from bin/kill) kill.c and use just
the one in kill.c (which is amended slightly so it can work
the way that trap.c needs it to work).    This one is chosen as
it was a much nicer implementation, and because while kill is
always built into the shell, kill also exists without the shell.

Leave the old implementation #if 0'd in trap.c (but updated to
match the calling convention of the one in kill.c) - for now.

Delete references of sys_signame[] from sh/trap.c and along with
that several uses of NSIG (unfortunately, there are still more)
and replace them with the newer libc functional interfaces.

Revision 1.45 / (download) - annotate - [select for diffs], Sun Aug 19 23:50:27 2018 UTC (5 years, 7 months ago) by kre
Branch: MAIN
CVS Tags: pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906
Changes since 1.44: +14 -2 lines
Diff to previous 1.44 (colored)

PR bin/48875 (is related, and ameliorated, but not exactly "fixed")

Import a whole set of tree evaluation enhancements from FreeBSD.

With these, before forking, the shell predicts (often) when all it will
have to do after forking (in the parent) is wait for the child and then
exit with the status from the child, and in such a case simply does not
fork, but rather allows the child to take over the parent's role.

This turns out to handle the particular test case from PR bin/48875 in
such a way that it works as hoped, rather than as it did (the delay there
was caused by an extra copy of the shell hanging around waiting for the
background child to complete ... and keeping the command substitution
stdout open, so the "real" parent had to wait in case more output appeared).

As part of doing this, redirection processing for compound commands gets
moved out of evalsubshell() and into a new evalredir(), which allows us
to properly handle errors occurring while performing those redirects,
and not mishandle (as in simply forget) fd's which had been moved out
of the way temporarily.

evaltree() has its degree of recursion reduced by making it loop to
handle the subsequent operation: that is instead of (for any binop
like ';' '&&' (etc)) where it used to
	evaltree(node->left);
	evaltree(node->right);
	return;
it now does (kind of)
	next = node;
	while ((node = next) != NULL) {
		next = NULL;

		if (node is a binary op) {
			evaltree(node->left);
			if appropriate /* if && test for success, etc */
				next = node->right;
			continue;
		}
		/* similar for loops, etc */
	}
which can be a good saving, as while the left side (now) tends to be
(usually) a simple (or simpleish) command, the right side can be many
commands (in a command sequence like a; b; c; d; ...  the node at the
top of the tree will now have "a" as its left node, and the tree for
b; c; d; ... as its right node - until now everything was evaluated
recursively so it made no difference, and the tree was constructed
the other way).

if/while/... statements are done similarly, recurse to evaluate the
condition, then if the (or one of the) body parts is to be evaluated,
set next to that, and loop (previously it recursed).

There is more to do in this area (particularly in the way that case
statements are processed - we can avoid recursion there as well) but
that can wait for another day.

While doing all of this we keep much better track of when the shell is
just going to exit once the current tree is evaluated (with a new
predicate at_eof() to tell us that we have, for sure, reached the end
of the input stream, that is, this shell will, for certain, not be reading
more command input) and use that info to avoid unneeded forks.   For that
we also need another new predicate (have_traps()) to determine of there
are any caught traps which might occur - if there are, we need to remain
to (potentially) handle them, so these optimisations will not occur (to
make the issue in PR 48875 appear again, run the same code, but with a
trap set to execute some code when a signal (or EXIT) occurs - note that
the trap must be set in the appropriate level of sub-shell to have this
effect, any caught traps are cleared in a subshell whenever one is created).

There is still work to be done to handle traps properly, whatever
weirdness they do (some of which is related to some of this.)

These changes do not need man page updates, but 48875 does - an update
to sh.1 will be forthcoming once it is decided what it should say...

Once again, all the heavy lifting for this set of changes comes directly
(with thanks) from the FreeBSD shell.

XXX pullup-8 (but not very soon)

Revision 1.44 / (download) - annotate - [select for diffs], Sun Jul 22 20:43:58 2018 UTC (5 years, 8 months ago) by kre
Branch: MAIN
CVS Tags: pgoyette-compat-0728
Changes since 1.43: +7 -5 lines
Diff to previous 1.43 (colored)

PR bin/36532 (perhaps)

This is more or less the same patch as provided in the PR
(just 11 years later, so changed a bit) by woods@...

Since there is no known way to actually cause the reported crash,
we may never know if this change actually fixes anything.   But
even if it doesn't it certainly cannot hurt.

There is a potential race which could possibly explain the issue
(see commentary in the PR) which is not easy to avoid - if that is
the actual cause, this should provide a defence, if not really a fix.

Revision 1.43 / (download) - annotate - [select for diffs], Sun Jul 22 20:42:50 2018 UTC (5 years, 8 months ago) by kre
Branch: MAIN
Changes since 1.42: +3 -5 lines
Diff to previous 1.42 (colored)


Revert previous, change has nothing to do with DEBUG mode.
COming again (correctly) in a few seconds.

Revision 1.42 / (download) - annotate - [select for diffs], Sun Jul 22 20:38:06 2018 UTC (5 years, 8 months ago) by kre
Branch: MAIN
Changes since 1.41: +7 -5 lines
Diff to previous 1.41 (colored)

DEBUG mode only change (ie: no effect to any normal shell).

Add tracing of pattern matching (aid in debugging various issues.)

Revision 1.41 / (download) - annotate - [select for diffs], Wed Jul 5 19:47:11 2017 UTC (6 years, 8 months ago) by kre
Branch: MAIN
CVS Tags: phil-wifi-base, pgoyette-compat-base, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646
Branch point for: phil-wifi, pgoyette-compat
Changes since 1.40: +13 -5 lines
Diff to previous 1.40 (colored)


DEBUG and white space changes only.   Convert TRACE() calls for DEBUg mode
to the new style.   NFC (when not debugging sh).

Revision 1.40 / (download) - annotate - [select for diffs], Sun May 7 15:01:18 2017 UTC (6 years, 10 months ago) by kre
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, netbsd-8-base
Branch point for: netbsd-8
Changes since 1.39: +114 -22 lines
Diff to previous 1.39 (colored)


Enhance the trap command to make it possible to do what POSIX wants
(even if no shell in existence, that I am aware of, does that).

That is, POSIX says ... [of the trap command with no args]

	The shell shall format the output, including the proper use of
	quoting, so that it is suitable for re-input to the shell as commands
	that achieve the same trapping results. For example:

	save_traps=$(trap)

	...

	eval "$save_traps"

It is obvious what the intent is there.  But no shell makes it work.

An example using bash (as the NetBSD shell, still does not do the save_traps=
stuff correctly - but that is a problem for a different time and place...)

Given this script

	printf 'At start: '; trap
	printf '\n'

	traps=$(trap)
	trap 'echo hello' INT
	printf 'inside  : '; trap
	printf '\n'
	eval "${traps}"

	printf 'At end  : '; trap
	printf '\n'

One would expect that (assuming no traps are set at the start, and
there aren't) that the first trap will print nothing, then the inside
trap will show the trap that was set, and then when we get to the
end everything will be back to nothing again.

But:

At start:
inside  : trap -- 'echo hello' SIGINT

At end  : trap -- 'echo hello' SIGINT

And of course. when you think about it, it is obvious why this happens.
The first "trap" command prints nothing ... nothing has changed when we
get to the "traps=$(trap)" command ... that trap command also prints
nothing.  So this does traps=''.  When we do eval "${traps}" we are
doing eval "", and it is hardly surprising that this accomplishes nothing!

Now we cannot rationally change the "trap" command without args to
behave in a way that would make it useful for the posix purpose (and
here, what they're aiming for is good, it should be possible to
accomplish that objective) so is there some other way?

I think I have seen some shell (but I do not remember which one) that
actually has "trap -" that resets all traps to the default, so with that,
if we changed the 'eval "${traps}"' line to 'trap -; eval "${traps}"'
then things would actually work - kind of - that version has race conditions,
so is not really safe to use (it will work, most of the time...)

But, both ksh93 and bash have a -p arg to "trap" that allows information
about the current trap status of named signals to be reported.  Unfortunately
they don't do quite the same thing, but that's not important right now,
either would be usable, and they are, but it is a lot of effort, not
nearly as simple as the posix example.

First, while "trap -p" (with no signals specified) works, it works just
the same (in both bash and ksh93, aside from output format) as "trap".
That is, that is useless.   But we can to

	trap_int=$(trap -p int)
	trap_hup=$(trap -p hup)
	...

and then reset them all, one by one, later...

(bash syntax)
	test -n "${trap_int}" && eval "${trap_int}" || trap - int
	test -n "${trap_hup}" && eval "${trap_hup}" || trap - hup
(ksh93 syntax)
	trap "${trap_int:-}" int
	trap "${trap_hup:-}" hup

the test (for bash) and  variable with default for ksh93, is needed
because they both still print nothing if the signal action is the default.

So, this modification attempts to fix all of that...

1) we add trap -p, but make it always output something for every signal
   listed (all of the signals if none are given) even if the signal
   action is the default.

2) choose the bash output format for trap -p, over the ksh93 format,
   even though the simpler usage just above makes the ksh93 form seem
   better.   But it isn't.  Consider:

	ksh93$ trap -p int hup
	echo hello

   One of the two traps has "echo hello" as its action, the other is
   still at the default, but which?

   From bash...
	bash$ trap -p int hup
	trap -- 'echo hello' SIGINT

   And now we know!  Given the bash 'trap -p' format, the following function
   produces ksh93 format output (for use with named signals only) instead...

	ksh93_trap_p() {
		for _ARG_ do
			_TRAP_=$(trap -p "${_ARG_}") || return 1
			eval set -- "${_TRAP_}"
			printf '%s' "$3${3:+
	}"
		done
		return 0
	}

  [ It needs to be entered without the indentation, that '}"' line has to be
    at the margin.   If the shell running that has local vars (bash does) then
    _ARG_ and _TRAP_ should be made local. ]

  So the bash format was chosen (except we do not include the "SIG" on the
  signal names.  That's irrelevant.)

  If no traps are set, "trap -p" will say (on NetBSD of course)...

trap -- - EXIT HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS
trap -- - PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ
trap -- - VTALRM PROF WINCH INFO USR1 USR2 PWR RT0 RT1 RT2 RT3 RT4 RT5
trap -- - RT6 RT7 RT8 RT9 RT10 RT11 RT12 RT13 RT14 RT15 RT16 RT17 RT18
trap -- - RT19 RT20 RT21 RT22 RT23 RT24 RT25 RT26 RT27 RT28 RT29 RT30

  Obviously if traps are set, the relevant signal names will be removed from
  that list, and additional lines added for the trapped signals.

  With args, the signals names are listed, one line each, whatever
  the status of the trap for that signal is:

$ trap -p HUP INT QUIT
trap -- - HUP
trap -- 'echo interrupted' INT
trap -- - QUIT

3) we add "trap -" to reset all traps to default.   (It is easy, and seems
   useful.)

4) While here, lots of generic cleanup.   In particular, get rid of the
   NSIG+1 nonsense, and anything that ever believes a signo == NSIG
   is in any way rational.   Before there was a bunch of confusion,
   as we need all the signals for traps, plus one more for the EXIT
   trap, which looks like we then need NSIG+1.  But EXIT is 0, NSIG
   includes signals from 0..NSIG-1 but there is no signal 0, EXIT
   uses that slot, so we do not need to add and extra one, NSIG is
   enough.   (To see the effect of this, use a /bin/sh from before
   this fix, and compare the output from

	trap '' 64
   and  trap '' 65

   both invalid signal numbers.

   Then try just "trap" and watch your shell drop core...)

   Eventually NSIG needs to go away completely (from user apps), it
   is not POSIX, it isn't really useful (unless we make lots of
   assumptions about how signals are numbered, which are not guaranteed,
   so even if apps, like this sh, work on NetBSD, they're not portable,)
   and it isn't necessary (or will not be, soon.)

   But that is for another day...

5) As is kind of obvious above, when listing "all" traps, list all the
   ones still at their defaults, and all the ignored signals, on as
   few lines as possible (it could all be on one line - technically it
   would work as well, but it would have made this cvs log message
   really ugly...)   Signals with a non-null action still get listed
   one to a line (even if several do have the exact same action.)

6) Man page updates as well.

After this change, the following script:

	printf 'At start: '; trap
	printf '\n'

	trap -p >/tmp/out.$$
	trap 'echo hello' INT
	printf 'inside  : '; trap
	printf '\n'
	. /tmp/out.$$; rm /tmp/out.$$

	printf 'At end  : '; trap
	printf '\n'

which is just the example from above,
using "trap -p" instead of just "trap" to save the traps,
and modified to a form that will work with the NetBSD shell today
produces:

At start:
inside  : trap -- 'echo hello' INT

At end  :

[Do I get a prize for longest commit log message of the year?]

Revision 1.39 / (download) - annotate - [select for diffs], Sat Apr 29 15:12:21 2017 UTC (6 years, 11 months ago) by kre
Branch: MAIN
CVS Tags: prg-localcount2-base1
Changes since 1.38: +35 -26 lines
Diff to previous 1.38 (colored)


Fix several problems with the implementation of the "trap" command
(that is, with the command itself, not with the traps that are
executed, if any).

- "trap -- -l" is not rational, permit the (non-std) -l option only
  when given as the sole arg (ie: "trap -l").
- "trap --" is the same as just "trap" (and -- is ignored for below)
- "trap action" generates a usage message (there must be at least one condition)
- "trap N [condition...]" (the old form with a numeric first arg, to reset
  traps to default, instead of "trap - condition...") is properly detected.
  In particular while "trap 1 2 3" resets sighup sigint and siquit handlers
  to default, "trap hup int quit" runs the "hup" command on sigint or sigquit
  and does nothing to sighup at all.
- actions can start with "-" (as can commands in general) - it may be unusual
  or even unwise, but it is not prohibited, and should work
- bad conditions (signal names/numbers) are just a usage error (resulting in
  non-zero "exit status" (and a diagnostic on stderr)) they do not cause
  the script to abort (as a syntax error in a special builtin would.)
  (so says posix, very explicitly.)
- when outputting the trap list ("trap") properly quote null actions
  (ignored conditions).  This has the side effect of also generating an
  explicit null string ('') in other cases where null values are output,
  such as when reporting var values ("set") but that's OK, and might be
  better (VAR= and VAR='' mean the same, but the latter is more obvious.)

We still do not properly handle traps=$(trap) (ie: it does not work at all,
and should) but that's a different problem that needs fixing in another place.

Revision 1.38 / (download) - annotate - [select for diffs], Wed Apr 26 22:41:53 2017 UTC (6 years, 11 months ago) by kre
Branch: MAIN
Changes since 1.37: +6 -3 lines
Diff to previous 1.37 (colored)


Deal with traps that reset the (same) trap in the trap handler
(avoid referrencing memory that might have been freed).
From FreeBSD (ages ago, just not committed until now...)

Revision 1.37 / (download) - annotate - [select for diffs], Sat Aug 22 12:12:47 2015 UTC (8 years, 7 months ago) by christos
Branch: MAIN
CVS Tags: prg-localcount2-base, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: prg-localcount2
Changes since 1.36: +11 -2 lines
Diff to previous 1.36 (colored)

report the signal that wait was interrupted by, which is not always SIGINT
anymore.

Revision 1.36 / (download) - annotate - [select for diffs], Sat Aug 22 09:55:23 2015 UTC (8 years, 7 months ago) by christos
Branch: MAIN
Changes since 1.35: +4 -4 lines
Diff to previous 1.35 (colored)

Process pending signals while waiting for a job:
    $ cat << EOF > hup.sh
    #!/bin/sh
    trap 'echo SIGHUP; exit 1' 1
    sleep 10000 &
    wait
    EOF
    $ chmod +x ./hup.sh
    $ ./hup.sh &
    $ kill -HUP %1

Revision 1.35 / (download) - annotate - [select for diffs], Sat Jun 18 21:18:46 2011 UTC (12 years, 9 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-7-base, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, khorben-n900, agc-symver-base, agc-symver
Branch point for: netbsd-7, netbsd-6
Changes since 1.34: +3 -2 lines
Diff to previous 1.34 (colored)

PR/45069: Henning Petersen: Use prototypes from builtins.h .

Revision 1.34 / (download) - annotate - [select for diffs], Fri Feb 15 17:26:06 2008 UTC (16 years, 1 month ago) by matt
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, mjf-devfs2-base, mjf-devfs2, matt-premerge-20091211, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, matt-armv6-nbase, keiichi-mipv6-base, keiichi-mipv6, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, hpcarm-cleanup-nbase, hpcarm-cleanup-base, cherry-xenmp-base, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Branch point for: cherry-xenmp
Changes since 1.33: +3 -3 lines
Diff to previous 1.33 (colored)

Fix inconsistent definitions

Revision 1.33 / (download) - annotate - [select for diffs], Fri Jul 15 17:23:48 2005 UTC (18 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf, abandoned-netbsd-4-base, abandoned-netbsd-4
Branch point for: matt-armv6
Changes since 1.32: +17 -7 lines
Diff to previous 1.32 (colored)

Allow trap to work on ignored signals when the shell is interactive.

Revision 1.32 / (download) - annotate - [select for diffs], Mon Jul 11 02:37:05 2005 UTC (18 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.31: +27 -13 lines
Diff to previous 1.31 (colored)

Don't hard ignore signals that were ignored by our environment, because
when we try to set a trap on them it will not work. Also while I am here:
1. don't change the action status if the signal system call failed.
2. don't try to sigignore it if signal failed.
3. clear the signal mask in case our parent blocked it for us.

Revision 1.31 / (download) - annotate - [select for diffs], Tue Jan 11 19:38:57 2005 UTC (19 years, 2 months ago) by christos
Branch: MAIN
CVS Tags: netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3
Changes since 1.30: +9 -6 lines
Diff to previous 1.30 (colored)

PR/28940: David Laight: /bin/sh doesn't quote the output of trap.

Revision 1.30 / (download) - annotate - [select for diffs], Tue Aug 26 18:13:25 2003 UTC (20 years, 7 months ago) by jmmv
Branch: MAIN
CVS Tags: netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-base, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2-0, netbsd-2
Changes since 1.29: +5 -5 lines
Diff to previous 1.29 (colored)

Use '\0' instead of NULL in two checks (we are not checking for a pointer
value).  While here, add a missing whitespace.

Revision 1.29 / (download) - annotate - [select for diffs], Thu Aug 7 09:05:39 2003 UTC (20 years, 7 months ago) by agc
Branch: MAIN
Changes since 1.28: +3 -7 lines
Diff to previous 1.28 (colored)

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.

Revision 1.28 / (download) - annotate - [select for diffs], Sun Nov 24 22:35:43 2002 UTC (21 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: fvdl_fs64_base
Changes since 1.27: +17 -35 lines
Diff to previous 1.27 (colored)

Fixes from David Laight:
- ansification
- format of output of jobs command (etc)
- job identiers %+, %- etc
- $? and $(...)
- correct quoting of output of set, export -p and readonly -p
- differentiation between nornal and 'posix special' builtins
- correct behaviour (posix) for errors on builtins and special builtins
- builtin printf and kill
- set -o debug (if compiled with DEBUG)
- cd src obj (as ksh - too useful to do without)
- unset -e name, remove non-readonly variable from export list.
  (so I could unset -e PS1 before running the test shell...)

Revision 1.27 / (download) - annotate - [select for diffs], Fri Sep 27 18:56:56 2002 UTC (21 years, 6 months ago) by christos
Branch: MAIN
Changes since 1.26: +34 -23 lines
Diff to previous 1.26 (colored)

VFork()ing shell: From elric@netbsd.org:
Plus my changes:
	- walking process group fix in foregrounding a job.
	- reset of process group in parent shell if interrupted before the wait.
	- move INTON lower in the dowait so that the job structure is
	  consistent.
	- error check all setpgid(), tcsetpgrp() calls.
	- eliminate unneeded strpgid() call.
	- check that we don't belong in the process group before we try to
	  set it.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Mar 18 04:04:23 2001 UTC (23 years ago) by wulf
Branch: MAIN
CVS Tags: netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6, ELRICshvfork-base
Branch point for: ELRICshvfork
Changes since 1.25: +83 -8 lines
Diff to previous 1.25 (colored)

Extended functionality of the trap builtin, which now closely follows
POSIX recommendations.

	- trap now accepts signal names and signal numbers
	  e.g. INT, SIGINT, 2
	- added option -l that outputs a list of valid signals
	- added signal EXIT to list of valid signals
	- a `-' in the action part will reset specified signal to their
	  default behaviour
	- changed standard output format to make it suitable as an input
	  to another shell that achieves the same trapping results

Revision 1.25 / (download) - annotate - [select for diffs], Sun Feb 4 19:52:07 2001 UTC (23 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.24: +2 -4 lines
Diff to previous 1.24 (colored)

remove redundant declarations and nexted externs.

Revision 1.24 / (download) - annotate - [select for diffs], Mon May 22 10:18:47 2000 UTC (23 years, 10 months ago) by elric
Branch: MAIN
CVS Tags: netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, minoura-xpg4dl-base, minoura-xpg4dl
Branch point for: netbsd-1-5
Changes since 1.23: +21 -32 lines
Diff to previous 1.23 (colored)

Back out previous vfork changes.

Revision 1.23 / (download) - annotate - [select for diffs], Sat May 13 20:50:15 2000 UTC (23 years, 10 months ago) by elric
Branch: MAIN
Changes since 1.22: +34 -23 lines
Diff to previous 1.22 (colored)

Now we use vfork(2) instead of fork(2) when we can.

Revision 1.22 / (download) - annotate - [select for diffs], Thu Jan 27 23:39:41 2000 UTC (24 years, 2 months ago) by christos
Branch: MAIN
Changes since 1.21: +4 -4 lines
Diff to previous 1.21 (colored)

Fix bin/9184, bin/9194, bin/9265, bin/9266
Exitcode and negation problems (From Martin Husemann)

Revision 1.21 / (download) - annotate - [select for diffs], Sat Mar 27 13:46:19 1999 UTC (25 years ago) by christos
Branch: MAIN
CVS Tags: wrstuden-devbsize-base, wrstuden-devbsize-19991221, wrstuden-devbsize, netbsd-1-4-base, netbsd-1-4-RELEASE, netbsd-1-4-PATCH003, netbsd-1-4-PATCH002, netbsd-1-4-PATCH001, netbsd-1-4, comdex-fall-1999-base, comdex-fall-1999
Changes since 1.20: +3 -3 lines
Diff to previous 1.20 (colored)

When we execute commands from a shell script, make sure that the signals
are being caught (reported by Alexis Rosen), similar to the -c case.

#!/bin/sh
vi "$@"

^C when the script is running...

Revision 1.20 / (download) - annotate - [select for diffs], Fri Feb 5 21:21:27 1999 UTC (25 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.19: +3 -3 lines
Diff to previous 1.19 (colored)

Fix the -c problem differently. We cannot just ignore SIGINT etc, otherwise
we cannot interrupt sh -c <command>

Revision 1.19 / (download) - annotate - [select for diffs], Mon Jan 18 16:18:04 1999 UTC (25 years, 2 months ago) by christos
Branch: MAIN
Changes since 1.18: +3 -2 lines
Diff to previous 1.18 (colored)

PR/6213: Urban Boquist: /bin/sh does not handle a trapped signal correctly
	 The problem was that system calls got restarted after a signal,
	 instead of returning EINTR. Thus the read builtin, had no way to
	 know that a signal occured that could change the course of execution.
	 Since the code has sprinkled checks for EINTR all over the place,
	 it is supposed to work properly with non restartable syscalls.
	 The fix is to use siginterrupt(signo, 1), before setting a signal
	 handler, to make sure that system calls don't get restarted.

Revision 1.18 / (download) - annotate - [select for diffs], Tue Jul 28 05:31:28 1998 UTC (25 years, 8 months ago) by mycroft
Branch: MAIN
Changes since 1.17: +3 -2 lines
Diff to previous 1.17 (colored)

Delint.

Revision 1.17 / (download) - annotate - [select for diffs], Fri Jul 4 21:02:24 1997 UTC (26 years, 9 months ago) by christos
Branch: MAIN
CVS Tags: netbsd-1-3-base, netbsd-1-3-RELEASE, netbsd-1-3-PATCH003-CANDIDATE2, netbsd-1-3-PATCH003-CANDIDATE1, netbsd-1-3-PATCH003-CANDIDATE0, netbsd-1-3-PATCH003, netbsd-1-3-PATCH002, netbsd-1-3-PATCH001, netbsd-1-3-BETA, netbsd-1-3
Changes since 1.16: +3 -3 lines
Diff to previous 1.16 (colored)

Fix compiler warnings.

Revision 1.16 / (download) - annotate - [select for diffs], Wed Oct 16 15:45:19 1996 UTC (27 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.15: +12 -12 lines
Diff to previous 1.15 (colored)

PR/2808: Remove trailing whitespace (from FreeBSD)

Revision 1.15 / (download) - annotate - [select for diffs], Wed Jun 7 04:16:57 1995 UTC (28 years, 9 months ago) by christos
Branch: MAIN
CVS Tags: netbsd-1-2-base, netbsd-1-2-RELEASE, netbsd-1-2-BETA, netbsd-1-1-base, netbsd-1-1-RELEASE, netbsd-1-1-PATCH001, netbsd-1-1
Branch point for: netbsd-1-2
Changes since 1.14: +17 -12 lines
Diff to previous 1.14 (colored)

Ignore result of sigaction when setting traps. Traps will succeed even
on SIGKILL or SIGSTOP. This is what other bourne shells do. (suggested
by mycroft)

Revision 1.14 / (download) - annotate - [select for diffs], Mon Jun 5 14:24:33 1995 UTC (28 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.13: +6 -1 lines
Diff to previous 1.13 (colored)

Avoid trapping SIGKILL. Pretend that we did, so that we will not keep
failing trying to trap it later. This is what the other bourne shells do.

Revision 1.13 / (download) - annotate - [select for diffs], Thu May 11 21:30:28 1995 UTC (28 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.12: +8 -5 lines
Diff to previous 1.12 (colored)

Merge in my changes from vangogh, and fix the x=`false`; echo $? == 0
bug.

Revision 1.12 / (download) - annotate - [select for diffs], Tue Mar 21 09:10:25 1995 UTC (29 years ago) by cgd
Branch: MAIN
Changes since 1.11: +7 -2 lines
Diff to previous 1.11 (colored)

convert to new RCS id conventions.

Revision 1.11 / (download) - annotate - [select for diffs], Fri Dec 23 13:24:43 1994 UTC (29 years, 3 months ago) by cgd
Branch: MAIN
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

be more careful with casts.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Dec 5 19:07:57 1994 UTC (29 years, 4 months ago) by cgd
Branch: MAIN
Changes since 1.9: +24 -8 lines
Diff to previous 1.9 (colored)

clean up further.  more patches from Jim Jegers

Revision 1.9 / (download) - annotate - [select for diffs], Sat Jun 11 16:12:37 1994 UTC (29 years, 9 months ago) by mycroft
Branch: MAIN
CVS Tags: netbsd-1-0-base, netbsd-1-0-RELEASE, netbsd-1-0-PATCH1, netbsd-1-0-PATCH06, netbsd-1-0-PATCH05, netbsd-1-0-PATCH04, netbsd-1-0-PATCH03, netbsd-1-0-PATCH02, netbsd-1-0-PATCH0, netbsd-1-0
Changes since 1.8: +2 -1 lines
Diff to previous 1.8 (colored)

Add RCS ids.

Revision 1.8 / (download) - annotate - [select for diffs], Thu May 12 23:55:26 1994 UTC (29 years, 10 months ago) by jtc
Branch: MAIN
Changes since 1.7: +9 -10 lines
Diff to previous 1.7 (colored)

last sys_signame[] changes; shell can now be built from scratch

Revision 1.7 / (download) - annotate - [select for diffs], Thu May 12 17:03:50 1994 UTC (29 years, 10 months ago) by jtc
Branch: MAIN
Changes since 1.6: +1 -0 lines
Diff to previous 1.6 (colored)

Include appropriate header files to bring function prototypes into scope.

Revision 1.6 / (download) - annotate - [select for diffs], Wed May 11 17:10:47 1994 UTC (29 years, 10 months ago) by jtc
Branch: MAIN
Changes since 1.5: +54 -33 lines
Diff to previous 1.5 (colored)

sync with 4.4lite

Revision 1.5 / (download) - annotate - [select for diffs], Fri Aug 6 21:50:18 1993 UTC (30 years, 7 months ago) by mycroft
Branch: MAIN
Changes since 1.4: +18 -19 lines
Diff to previous 1.4 (colored)

Use sys_signame[].

Revision 1.4 / (download) - annotate - [select for diffs], Sun Aug 1 18:57:59 1993 UTC (30 years, 8 months ago) by mycroft
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

Add RCS identifiers.

Revision 1.3 / (download) - annotate - [select for diffs], Tue Mar 23 00:29:28 1993 UTC (31 years ago) by cgd
Branch: MAIN
CVS Tags: netbsd-alpha-1, netbsd-0-9-base, netbsd-0-9-RELEASE, netbsd-0-9-BETA, netbsd-0-9-ALPHA2, netbsd-0-9-ALPHA, netbsd-0-9, netbsd-0-8
Changes since 1.2: +1 -1 lines
Diff to previous 1.2 (colored)

changed "Id" to "Header" for rcsids

Revision 1.2 / (download) - annotate - [select for diffs], Mon Mar 22 08:04:00 1993 UTC (31 years ago) by cgd
Branch: MAIN
Changes since 1.1: +1 -0 lines
Diff to previous 1.1 (colored)

added rcs ids to all files

Revision 1.1 / (download) - annotate - [select for diffs], Sun Mar 21 09:45:37 1993 UTC (31 years ago) by cgd
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>