aboutsummaryrefslogtreecommitdiff
path: root/win32/system.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-09-12 14:03:26 +0100
committerRon Yorston <rmy@pobox.com>2023-09-12 15:01:06 +0100
commit504f373c8d4447a4801a74887f99f0dfa809f53e (patch)
treeb96d61abd47657a60f8e1a194e31b1019f2a2be4 /win32/system.c
parentfaf0d38e40e099eebccac4013ab2692e545f612e (diff)
downloadbusybox-w32-504f373c8d4447a4801a74887f99f0dfa809f53e.tar.gz
busybox-w32-504f373c8d4447a4801a74887f99f0dfa809f53e.tar.bz2
busybox-w32-504f373c8d4447a4801a74887f99f0dfa809f53e.zip
make: return non-zero exit status when a command fails
When a build command returned a non-zero exit status 'make' reported a warning and returned an exit code of zero. This was due to the misuse of the status returned by system(3). As the man page says: the return value is a "wait status" that can be examined using the macros described in waitpid(2). (i.e., WIFEXITED(), WEXITSTATUS(), and so on). Use the error() function to correctly report the problem on stderr and return an exit status of 2. Some additional changes in the same area: - When a target is removed report the diagnostic on stderr, as required by POSIX. - When a build command receives a signal GNU make removes the target. bmake doesn't and it isn't required by POSIX. Implement this as an extension. - Expand the error message when a build command fails so it includes the exit status or signal number, as obtained from the value returned by system(3). - Alter the WIN32 implementation of system(3) to handle exit codes which represent termination as if by a signal. Adds 200-240 bytes. (GitHub issue #354)
Diffstat (limited to 'win32/system.c')
-rw-r--r--win32/system.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/win32/system.c b/win32/system.c
index 44a47f861..00b594242 100644
--- a/win32/system.c
+++ b/win32/system.c
@@ -6,6 +6,7 @@ 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;
9 10
10 if (cmd == NULL) 11 if (cmd == NULL)
11 return 1; 12 return 1;
@@ -18,5 +19,9 @@ int mingw_system(const char *cmd)
18 GetExitCodeProcess(h, &ret); 19 GetExitCodeProcess(h, &ret);
19 CloseHandle(h); 20 CloseHandle(h);
20 21
22 // Was process terminated as if by a signal?
23 sig = ret >> 24;
24 if (sig != 0 && ret == sig << 24 && is_valid_signal(sig))
25 return sig;
21 return ret << 8; 26 return ret << 8;
22} 27}