help-gnu-utils
[Top][All Lists]
Advanced

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

Re: gmake exit codes


From: Glynn Clements
Subject: Re: gmake exit codes
Date: 22 May 2004 03:06:48 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Security Through Obscurity)

"Mark Brandyberry" <address@hidden> writes:


> I am running a simple Perl script to build our code several ways each night.
> Something like:
> 
> system("gmake <options>");
> system("gmake clean");
> system("gmake <different options>");
> 
> etc.
> 
> There are 30 different builds, and most of them work fine, and gmake returns
> "0" as expected.  However, randomly (it seems), gmake appears to be
> returning "512" for 2 to 4 of the builds, and there doesn't seem to be a
> pattern of which ones will fail on any given night.  Worse, if I go and
> build the same source base by hand using the same options, it will always
> build fine.
> 
> The gnu make docs say that gmake will always return 0, 1, 2.  Should it ever
> be returning "512" to me? If so, what would it mean?

The entry for system() in the perlfunc(1) manpage says:

               The return value is the exit status of the program
               as returned by the wait() call.  To get the actual
               exit value divide by 256.  See also the exec entry
               elsewhere in this document.  This is NOT what you
               want to use to capture the output from a command,
               for that you should use merely backticks or qx//,
               as described in the section on `STRING` in the
               perlop manpage.

IOW, a value of 512 indicates that gmake terminated using exit(2) (or
the equivalent, e.g. returning 2 from main()).

It goes on to say:

               You can check all the failure possibilities by
               inspecting $? like this:

                   $exit_value  = $? >> 8;
                   $signal_num  = $? & 127;
                   $dumped_core = $? & 128;

IOW, bits 8-15 of the exit status contain the exit code (for normal
termination), bits 0-6 contain the fatal signal (for abnormal
termination), and bit 7 is set if the program dumped core.

-- 
Glynn Clements <address@hidden>


reply via email to

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