From 6cc8ebb4c7209e11827e7f561ba327283928f2eb Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 16 Jun 2016 01:44:10 +0000 Subject: Add workaround for libc problem with termination status macros, so they work with constant argument git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2788 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libsystem.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/libsystem.c') diff --git a/lib/libsystem.c b/lib/libsystem.c index e13a20ac..9491c03a 100644 --- a/lib/libsystem.c +++ b/lib/libsystem.c @@ -320,12 +320,24 @@ signalName(unsigned int const signalClass) { const char * -pm_termStatusDesc(int const termStatus) { +pm_termStatusDesc(int const termStatusArg) { /*---------------------------------------------------------------------------- English description of process termination status 'termStatus'. -----------------------------------------------------------------------------*/ const char * retval; + /* WIFEXITED, etc. do not work with a constant argument in older GNU C + library. Compilation fails with "attempt to assign read-only + location". This is because The GNU C library has some magic to allow + for a BSD 'union wait' (instead of int) argument to WIFEXITED. The + magic involves defining a variable with 'typeof' the argument and + assigning to that variable. + + To work around this, we make sure the argument is not constant. + */ + + int termStatus = termStatusArg; + if (WIFEXITED(termStatus)) { int const exitStatus = WEXITSTATUS(termStatus); -- cgit 1.4.1