aboutsummaryrefslogtreecommitdiff
path: root/win32/system.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-09-14 08:09:14 +0100
committerRon Yorston <rmy@pobox.com>2023-09-14 08:09:14 +0100
commit0475b7a649209487269e35cbe49662a33524e6ae (patch)
tree531237e1d8716e7c94fdcd0b2966e2e0cbfc0255 /win32/system.c
parente3d50157ce21f990c33afdcf8dba8080308ce0f0 (diff)
downloadbusybox-w32-0475b7a649209487269e35cbe49662a33524e6ae.tar.gz
busybox-w32-0475b7a649209487269e35cbe49662a33524e6ae.tar.bz2
busybox-w32-0475b7a649209487269e35cbe49662a33524e6ae.zip
win32: convert exit codes
Add two utility functions to convert Windows process exit codes. - exit_code_to_wait_status() converts to a POSIX wait status. This is used in ash and the implementations of system(3) and mingw_wait3(). - exit_code_to_posix() converts to a POSIX exit code. (Not that POSIX has much to say about them.) As a result it's possible for more applets to report when child processes are killed as if by a signal. 'time', 'drop' and 'su -W', for example. Adds 64-80 bytes.
Diffstat (limited to 'win32/system.c')
-rw-r--r--win32/system.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/win32/system.c b/win32/system.c
index 00b594242..c718d9948 100644
--- a/win32/system.c
+++ b/win32/system.c
@@ -6,7 +6,6 @@ int mingw_system(const char *cmd)
6 intptr_t proc; 6 intptr_t proc;
7 HANDLE h; 7 HANDLE h;
8 DWORD ret = 0; 8 DWORD ret = 0;
9 int sig;
10 9
11 if (cmd == NULL) 10 if (cmd == NULL)
12 return 1; 11 return 1;
@@ -19,9 +18,5 @@ int mingw_system(const char *cmd)
19 GetExitCodeProcess(h, &ret); 18 GetExitCodeProcess(h, &ret);
20 CloseHandle(h); 19 CloseHandle(h);
21 20
22 // Was process terminated as if by a signal? 21 return exit_code_to_wait_status(ret);
23 sig = ret >> 24;
24 if (sig != 0 && ret == sig << 24 && is_valid_signal(sig))
25 return sig;
26 return ret << 8;
27} 22}