bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libvirt] [PATCH] virsh: change wexitstatus order to allow compilati


From: Bruno Haible
Subject: Re: [libvirt] [PATCH] virsh: change wexitstatus order to allow compilation on mac osx
Date: Wed, 15 Sep 2010 20:41:25 +0200
User-agent: KMail/1.9.9

Hi Eric,

> #define _W_INT(w)       (*(int *)&(w))  /* convert union wait to int */
> ...
> Obviously, the Darwin folks are (mistakenly) assuming that you would 
> only ever use WEXITSTATUS with a 'union wait' lvalue

No, it is assuming that the WEXITSTATUS argument is an lvalue, of type
'int' or 'union wait'. The use of 'union wait' is very rare for 10 years
already, but old programs still need it.

> Since WEXITSTATUS should be usable on constants

Who says that? POSIX [1] says that the argument of WEXITSTATUS has to be
an integer value returned by wait() or waitpid() function in the *stat_loc
location.

> it is a bug in their headers, and one that Gnulib should be  
> able to work around.

I disagree. It is a crazy idea to call WEXITSTATUS(0) if wait() or waitpid()
hasn't return a *stat_loc value of 0. Therefore, almost all correct programs
call WEXITSTATUS on a variable that is usually of type 'int'.

It is a bug in their headers that you can't write WEXITSTATUS(get_last_stat()),
but it is easy enough to work around and rarely occurs.

And the workaround would have to be tricky: If you wanted to write an override
for the WEXITSTATUS macro, how would you write it in a way that it supports
'int' arguments but also 'union wait' arguments - for old BSD compatibility -,
without taking the address of the argument?

Bruno

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/wait.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]