tech-userlevel archive

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

Re: style, sysexits(3), and man RETURN VALUES for sys programs



Le Sat, Jun 03, 2023 at 11:28:31PM +0700, Robert Elz a écrit :
>     Date:        Sat, 3 Jun 2023 13:45:44 +0200
>     From:        tlaronde%polynum.com@localhost
>     Message-ID:  <ZHsn6PJtAkGjE1NY%polynum.com@localhost>
> 
>   | Rhialto pointed me to sysexits(3) that was exactly what I was looking
>   | for (for inetd(8) revision). So kudos to him!
> 
> I deliberately didn't mention sysexits.h (or sysexits(3)) as I don't
> think it is really appropriate here.
> 
> sysexits works when the calling program (one which execs & then waits for
> the one which is to use those exit values) understands the convention, and
> can take action based upon the different exit codes.
> 

But there is such a calling framework: it is called rc(8).

That's the rc(8) that "ensures" (it can't if it is not called) that
there is only one inetd(8) server; the program by itself has strictly no
code to ensure that another server is not running...

In the man page states: "should be run at boot time by /etc/rc"

but it is not "should": it is "shall" because nothing else ensure
uniqness.

Since rc(8) is an automated framework, it has to understand exit values
and certainly not to parse variable strings (why not confront rc(8) with
i18n or l10n then?).

Furthermore, you seem all to be OK with the fact that if a user asks:
"Do integers wear white socks?", the program shall answer: "NO". I'm
sorry, but the correct answer is: "NONSENSE" unless you want the user to
ask: "Their socks are black then?"

For rc(8), if every program handled by rc(8) was exiting with EX_USAGE,
it would be a piece of cake to verify before release that rc(8) is at
least up to date with the calling convention of the programs it handles.

So, I use sysexits(3) in inetd(8) since if 0 for OK and whatever for
anything else will do, sysexits(3) is a choice that is not less
legitimate than anything else.

And I do claim that sysexits was and still is a good idea ;-)
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index