GNO's _exit (contrary to its man page) does clean-up for stuff like the memory allocator, which is inappropriate in a forked child process and leads to hangs and crashes.
*Use .null instead of /dev/null
*Account for GNO's dup2(), which non-standardly returns 0 on success
*Always call open with appropriate number of arguments
*Use STDIN_FILENO instead of (implicitly) 0
In particular, it will buffer information about children other than the one being waited for, so it isn't lost. It can also emulate a non-blocking wait by arranging to interrupt the wait with a signal.
This involved breaking things up into more segments in debug mode, since the code is larger. I also had to remove some unused extern definitions, which were causing link errors when debug code was enabled.
To enable debug code, pass "DEBUG=1" to make or build.gs.
At this point, hush can successfully build and run, although it doesn't work correctly.
The main Makefile is now dedicated to the GNO build. There's now a separate makefile for building on modern systems with GCC/Clang.
It would have been possible to add a version of strftime(), but it didn't seem worth it for this little bit of functionality. It should also be possible to get similar functionality by invoking an external program like "date" in PS1.
This involved using signal() rather than sigaction(), which GNO doesn't have. signal() doesn't have the signal-blocking feature of sigaction(), but I've tried to emulate it.
This code could theoretically break if the ORCA/C varargs implementation changed, but it should be OK in practice.
Also removed some unused code in libbb/xfuncs.printf.c that includes potentially problematic varargs use (defining varargs functions but not necessarily calling va_start/va_end in them).
This disables long argument support, since that requires getopt_long(), which isn't included in GNO. There is a separate library available for it, but it's simpler to avoid depending on that.
This is a BSD-licensed poll() implementation by Brian M. Clapper. Its performance characteristics aren't as good as a "native" poll() would be, but this shouldn't be a problem in practice.
Dmake gets confused if you use over-15-character file names, so they needed to be shortened to get it to work. While I was at it, I also switched _ to . in the filenames so they're fully ProDOS compatible.
The shell/hush_test directory (not needed to build the code) still uses ProDOS-incompatible file names.
GNO doesn't actually implement glob, although it has a header for it. The GNO header is from an old BSD version and is missing some constants we need, so don't use it.
The offset to jitter ratio is now calculated before updating
jitter to make the test more sensitive.
function old new delta
ntp_init 460 474 +14
update_local_clock 752 764 +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 26/0) Total: 26 bytes
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>