Go to file
martin 547d772d41 Pull up following revision(s) (requested by kre in ticket #1259):
bin/sh/jobs.h: revision 1.24
	bin/sh/eval.c: revision 1.182
	bin/sh/jobs.c: revision 1.110

Related to PR bin/48875

Correct an issue found by Oguz <oguzismailuysal@gmail.com> and reported
in e-mail (on the bug-bash list initially!) with the code changed to deal
with PR bin/48875

With:
	 sh -c 'echo start at $SECONDS;
			(sleep 3 & (sleep 1& wait) );
		echo end at $SECONDS'

The shell should say "start at 0\nend at 1\n", but instead (before
this fix, in -9 and HEAD, but not -8) does "start at 0\nend at 3\n"
(Not in -8 as the 48875 changes were never pulled up)>

There was an old problem, fixed years ago, which cause the same symptom,
related to the way the jobs table was cleared (or not) in subshells, and
it seemed like that might have resurfaced.

But not so, the issue here is the sub-shell elimination, which was part
of the 48875 "fix" (not really, it wasn't really a bug, just sub-optimal
and unexpected behaviour).

What the shell actually has been running in this case is:

	 sh -c 'echo start at $SECONDS;
			(sleep 3 & sleep 1& wait );
		echo end at $SECONDS'

as the inner subshell was deemed unnecessary - all its parent would
do is wait for its exit status, and then exit with that status - we
may as well simply replace the current sub-shell with the new one,
let it do its thing, and we're done...

But not here, the running "sleep 3" will remain a child of that merged
sub-shell, and the "wait" will thus wait for it, along with the sleep 1
which is all it should be seeing.

For now, fix this by not eliminating a sub-shell if there are existing
unwaited upon children in the current one.  It might be possible to
simply disregard the old child for the purposes of wait (and "jobs", etc,
all cmds which look at the jobs table) but the bookkeeping required to
make that work reliably is likely to take some time to get correct...

Along with this fix comes a fix to DEBUG mode shells, which, in situations
like this, could dump core in the debug code if the relevant tracing was
enabled, and add a new trace for when the jobs table is cleared (which was
added predating the discovery of the actual cause of this issue, but seems
worth keeping.)   Neither of these changes have any effect on shells
compiled normally.

XXX pullup -9
2021-04-28 09:58:42 +00:00
bin Pull up following revision(s) (requested by kre in ticket #1259): 2021-04-28 09:58:42 +00:00
common Pull up following revision(s) (requested by skrll in ticket #1254): 2021-04-26 18:34:28 +00:00
compat Pull up following revision(s) (requested by simonb in ticket #1183): 2021-01-08 13:00:49 +00:00
crypto Pull up following revision(s) (requested by mrg in ticket #1246): 2021-04-16 17:03:59 +00:00
dist/pf - enlarge buffer to avoid snprintf() truncation 2019-02-03 10:48:46 +00:00
distrib Pull up following revision(s) (requested by tsutsui in ticket #1163): 2020-12-28 20:15:16 +00:00
doc Fix entry for ticket #1257 2021-04-28 04:54:19 +00:00
etc Pull up following revision(s) (requested by sborrill in ticket #1230): 2021-03-09 16:01:24 +00:00
external Pull up following revision(s) (requested by cjep in ticket #1253): 2021-04-25 18:29:56 +00:00
extsrc
games Pull up following revision(s) (requested by sevan in ticket #969): 2020-06-21 10:39:58 +00:00
include Pull up following revision(s) (requested by is in ticket #1135): 2020-11-29 11:25:31 +00:00
lib Pull up the following (all via patch), requested by mrg in ticket #1221: 2021-03-05 13:34:19 +00:00
libexec Pull up the following (all via patch), requested by mrg in ticket #1221: 2021-03-05 13:34:19 +00:00
regress Eliminate regress/libexec/ld.elf_so/expand 2019-04-06 16:25:52 +00:00
rescue Pull up following revision(s) (requested by maya in ticket #435): 2019-11-17 07:04:33 +00:00
sbin Pull up following revision(s) (requested by tsutsui in ticket #1184): 2021-01-09 19:30:14 +00:00
share Pull up following revision(s) (requested by nia in ticket #1232), 2021-03-22 17:15:16 +00:00
sys Pull up following revision(s) (requested by rin in ticket #1258): 2021-04-28 09:46:39 +00:00
tests Pull up following revision(s) (requested by knakahara in ticket #1129): 2020-11-10 11:44:22 +00:00
tools Pull up following revision(s) (requested by mrg in ticket #1049): 2020-08-14 11:02:42 +00:00
usr.bin Pull up following revision(s) (requested by nia in ticket #1215): 2021-02-26 13:29:16 +00:00
usr.sbin Pull up following revision(s) (requested by nia in ticket #1251): 2021-04-25 11:07:45 +00:00
BUILDING Fix a typo 2019-05-08 14:03:57 +00:00
Makefile Pull up following revision(s) (requested by kamil in ticket #126): 2019-09-01 10:44:22 +00:00
Makefile.inc
README.md Tidy up a bit. 2018-10-23 15:44:42 +00:00
UPDATING Note update hickup build issue for uefi boot. 2019-07-27 07:55:18 +00:00
build.sh Fix long-term broken pattern match when determining if uname -p output is 2019-06-07 15:49:20 +00:00

README.md

NetBSD

NetBSD is a free, fast, secure, and highly portable Unix-like Open Source operating system. It is available for a wide range of platforms, from large-scale servers and powerful desktop systems to handheld and embedded devices.

Building

You can cross-build NetBSD from most UNIX-like operating systems. To build for amd64 (x86_64), in the src directory:

./build.sh -U -u -j4 -m amd64 -O ~/obj release

Additional build information available in the BUILDING file.

Binaries

Testing

On a running NetBSD system:

cd /usr/tests; atf-run | atf-report

Troubleshooting

Latest sources

To fetch the main CVS repository:

cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P src

To work in the Git mirror, which is updated every few hours from CVS:

git clone https://github.com/NetBSD/src.git