From owner-svn-src-all@FreeBSD.ORG Thu Jan 17 20:39:33 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BAA37AD4; Thu, 17 Jan 2013 20:39:33 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (garage.dawidek.net [91.121.88.72]) by mx1.freebsd.org (Postfix) with ESMTP id 1E68FF93; Thu, 17 Jan 2013 20:39:32 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id A46DDAFA; Thu, 17 Jan 2013 21:36:54 +0100 (CET) Date: Thu, 17 Jan 2013 21:39:55 +0100 From: Pawel Jakub Dawidek To: John Baldwin Subject: Re: svn commit: r245506 - head/bin/pwait Message-ID: <20130117203955.GA1679@garage.freebsd.pl> References: <201301161815.r0GIFQPk007553@svn.freebsd.org> <20130117130740.I1066@besplex.bde.org> <201301171050.07596.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5vNYLRcllDrimb99" Content-Disposition: inline In-Reply-To: <201301171050.07596.jhb@freebsd.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@freebsd.org, Eitan Adler , svn-src-all@freebsd.org, Xin LI , Bruce Evans , svn-src-head@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 20:39:33 -0000 --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 wrote: > > > This uses the sysexits mistake. style(9) was fixed to not give an ex= ample > > > of this mistake. Before this, sysexits was used a whole once in pwai= t(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 e= ven > > > use '.Std' for this, but hard-codes it. > >=20 > > 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. >=20 > Eh, I think bde@ has quite a bit more experience with this than you. =20 > is not part of POSIX or any other standard. It's comments= =20 > reference delivermail (the predecessor to sendmail). Looking at its hist= ory,=20 > it has never been changed in FreeBSD, and it's history in CSRG is rather= =20 > spartan and mostly tied to delivermail/sendmail: >=20 > http://svnweb.freebsd.org/csrg/include/sysexits.h?view=3Dlog >=20 > In practice it's list of error value is limited and has not grown to hand= le=20 > new errors in over two decades (as opposed to, say, the list of errnos). = =20 > OTOH, it seems the history section in sysexits(3) is slightly off as the = CSRG=20 > 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. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --5vNYLRcllDrimb99 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlD4YZsACgkQForvXbEpPzTVJwCgv7hEhx7XqKq959ILjHqsKkiq URMAnij4tkluaEFmgxIN8FkL7L6tvuoy =bJeC -----END PGP SIGNATURE----- --5vNYLRcllDrimb99--