diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-12-28 06:19:18 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-12-28 06:19:18 -0800 |
commit | e0dfdb601d2ef16ea97bea1eebbf7e81ba240263 (patch) | |
tree | 56784f8eda97a9d83859c0419d9945ec8982966b | |
parent | 5da0c2024c0d3dd065ece6f80968f2f433dfa2be (diff) | |
download | txr-e0dfdb601d2ef16ea97bea1eebbf7e81ba240263.tar.gz txr-e0dfdb601d2ef16ea97bea1eebbf7e81ba240263.tar.bz2 txr-e0dfdb601d2ef16ea97bea1eebbf7e81ba240263.zip |
cygwin: run, sh: mangle termination status word.
* stream.c (run): On Cygwin, the spawnvp function is
returning a 16 bit termination status word where the upper
8 bits is the termination status if the termination is normal,
otherwise the lower 8 bits holds a termination signal.
Let's massage it so that the function returns an integer
termnation status, or nil if the termination was abnormal,
same as we do on POSIX platforms with fork/wait.
-rw-r--r-- | stream.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -4751,6 +4751,16 @@ static val run(val command, val args) #else status = w_spawnvp(_P_WAIT, c_str(command, self), nargs, wargv); #endif +#ifdef __CYGWIN__ + /* Cygwin spawnvp reports regular termination status in upper 8 bits, and + * termination signal in lower 8 bits. Let's massage it so that we produce + * the same behavior as on Linux. + */ + if (status && status < 0x100) + status = -1; /* ensure nil return */ + else + status >>= 8; +#endif } free(strip_qual(wchar_t **, wargv)); |