bug-coreutils
[Top][All Lists]
Advanced

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

Re: system.h cleanups


From: Pádraig Brady
Subject: Re: system.h cleanups
Date: Fri, 09 Oct 2009 10:47:25 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Eric Blake wrote:
> Pádraig Brady <P <at> draigBrady.com> writes:
> 
>> I'm not against this but EXIT_TIMEDOUT is specific to timeout.
>> Also I'd like to maintain the comments if possible.
> 
> Yes, comments help.
> 
>> Also stdbuf enums its own EXIT_CANCELED
> 
> Fixed in the respin below.

That's a nice cleanup which I see you've pushed.  Thanks.

>> I also noticed
>>
>> nohup enums NOHUP_FAILURE=127 which clashes with EXIT_ENOENT?
> 
> Required by POSIX to fail with 127 on internal failure (bummer).

Weird. POSIX does say that and includes the reason:

"The command, env, nice, nohup, time, and xargs utilities have been
specified to use exit code 127 if an error occurs so that applications
can distinguish "failure to find a utility" from "invoked utility
exited with an error indication". The value 127 was chosen because it
is not commonly used for other meanings; most utilities use small
values for "normal error conditions" and the values above 128 can be
confused with termination due to receipt of a signal. The value 126
was chosen in a similar manner to indicate that the utility could be
found, but not invoked. Some scripts produce meaningful error messages
differentiating the 126 and 127 cases. The distinction between exit
codes 126 and 127 is based on KornShell practice that uses 127 when
all attempts to exec the utility fail with [ENOENT], and uses 126 when
any attempt to exec the utility fails for any other reason."

Note however that env and nice are mentioned,
and the above paragraph is also included in their description,
but that they've been specified to use 125 on internal failure.
So that paragraph should be updated in POSIX at least
and maybe with clarification we could use EXIT_CANCELED in nohup
for consistency?

It deserves a comment at least:

diff --git a/src/nohup.c b/src/nohup.c
index 99bb865..d6865b4 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -39,8 +39,9 @@
 /* Exit statuses.  */
 enum
   {
-    /* `nohup' itself failed.  */
-    NOHUP_FAILURE = 127
+    /* `nohup' itself failed.  Generally EXIT_CANCELED is used
+       for internal failures, but POSIX specifies nohup to use 127.  */
+    NOHUP_FAILURE = EXIT_ENOENT
   };

> 
>> Also chroot, ence, nice and su only use EXIT_FAILURE?
> 
> chroot and su have no POSIX basis; we could probably use EXIT_CANCELED 
> instead 
> of EXIT_FAILURE, but that would be a separate patch.
> 
> ence?  Did you mean env?  env and nice are required to fail with 1-125, but 
> you 
> are right that EXIT_CANCELED is probably more consistent than EXIT_FAILURE.  
> This would be the same patch as su and chroot, if we agree to make the change.

I think EXIT_CANCELED is better as it distinguishes errors and
is more consistent with other tools.

cheers,
Pádraig.





reply via email to

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