svn commit: r245506 - head/bin/pwait

Pawel Jakub Dawidek pjd at FreeBSD.org
Thu Jan 17 20:39:33 UTC 2013


On Thu, Jan 17, 2013 at 10:50:07AM -0500, John Baldwin wrote:
> On Wednesday, January 16, 2013 10:40:51 pm Eitan Adler wrote:
> > On 16 January 2013 21:25, Bruce Evans <brde at optusnet.com.au> wrote:
> > > This uses the sysexits mistake.  style(9) was fixed to not give an example
> > > of this mistake.  Before this, sysexits was used a whole once in pwait(1)
> > > (for EX_USAGE) in usage().  EX_USAGE happens to be 64.  As usual when the
> > > mistake is used, this is useless for humans (the usage message gives more
> > > info) and unusable for programs, especially since it is undocmented
> > > (pwait(1)'s man page just says ">0 if an error occurs".  It doesn't even
> > > use '.Std' for this, but hard-codes it.
> > 
> > IMHO using sysexits gives more signal than using a binary 0 or 1.  It
> > is a mistake to have changed style(9) to avoid using sysexits.
> > Instead the man page should detail the specific error that occurs
> > directly, or by reference to sysexit.
> 
> Eh, I think bde@ has quite a bit more experience with this than you.  
> <sysexits.h> is not part of POSIX or any other standard.  It's comments 
> reference delivermail (the predecessor to sendmail).  Looking at its history, 
> it has never been changed in FreeBSD, and it's history in CSRG is rather 
> spartan and mostly tied to delivermail/sendmail:
> 
> http://svnweb.freebsd.org/csrg/include/sysexits.h?view=log
> 
> In practice it's list of error value is limited and has not grown to handle 
> new errors in over two decades (as opposed to, say, the list of errnos).  
> OTOH, it seems the history section in sysexits(3) is slightly off as the CSRG 
> history suggests it was present in at least 4.2BSD.

Well, if we decide sysexits(3) are useless, then it would be nice to
recommend against using it in sysexits(3) manual page. Currently it is
rather seductive:

	According to style(9), it is not a good practice to call exit(3)
	with arbitrary values to indicate a failure condition when
	ending a program.  Instead, the pre-defined exit codes from
	sysexits should be used, so the caller of the process can get a
	rough estimation about the failure class without looking up the
	source code.

I, for one, used it pretty extensively in HAST:)

	% grep EX_ /usr/src/sbin/hastd/*.c | wc -l
	      67

In my humble opinion using sysexits(3) is better than just putting
exit(1) everywhere. Actually HAST or some of my other projects was
making decision about restarting a processes if the exit code was
EX_TEMPFAIL (if the failure was temporary it is fine to restart, if it
is not then better not to enter some infinite loop). I am fully aware
that sysexits(3) doesn't cover many important cases, but those cases
differ from application to application.  The exact same problem exists
for errno. For me those values represent sets of failure cases rather
than allow to distinguish between every possible failure case.

It would probably be the best to define exit codes for every application
separately, but maybe selection of exit codes provided by sysexits(3) is
good enough and definiately better than 0/1.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20130117/9bb21f7e/attachment.sig>


More information about the svn-src-all mailing list