bug-hurd
[Top][All Lists]
Advanced

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

Re: fakeroot-hurd not properly returning errors


From: Ivan Shmakov
Subject: Re: fakeroot-hurd not properly returning errors
Date: Tue, 19 Aug 2014 19:55:43 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>>>>> Anatoly A Kazantsev <anatoly@gnu.org> writes:

[…]

 > @@ -348,9 +349,17 @@ main(int argc, char *argv[])
 >        break;

 >      default: /* Parent.  */
 > -      if (waitpid (pid, NULL, 0) == -1)
 > +      if (waitpid (pid, &status, 0) == -1)
 >          error (8, errno, "waitpid");

 > +      if (WIFSIGNALED (status))
 > +        error (WTERMSIG (status) + 128, 0,
 > +          "%s for child", strsignal (WTERMSIG (status)));
 > +
 > +      if (WIFEXITED (status))
 > +        error (WEXITSTATUS (status), 0,
 > +          "Error %d for child", WEXITSTATUS (status));
 > +
 >        err = fsys_goaway (active_control, goaway_flags);
 >        if (err && err != EBUSY)
 >          error (9, err, "fsys_goaway");

 > I have a question: why in case WIFSIGNALED the value of status is
 > increased by 128?

        When a program is terminated by a signal, its exit code is 128
        plus the number of that signal; consider, e. g.:

$ bash -c 'kill -8 -- $$' ; echo "Exit code: $?, Signal: $(($? - 128))" 
/bin/bash: line 1: 11876 Floating point exceptionbash -c 'kill -8 -- $$'
Exit code: 136, Signal: 8
$ 

        In this case, the utilities have to pass that exit code through,
        which is implemented as:

        1. “decoding” the status into a “terminated due to a signal”
           flag and /either/ the “plain” exit code /or/ the signal
           number;

        2. “encoding” these two values back into a single exit code,
           which is passed to exit () via error ().

        I don’t know where exactly this convention originated from, but
        I’m pretty sure that it was in every revision of POSIX ever
        published, and probably is almost as old as Unix itself.

[…]

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A



reply via email to

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