>> As with exit(), it can be replaced automatically with exits() but you
>> still have to figure out what message you want in your exits().
>
> If anyone is interested, this is what I used as a compatibility shim:
>
> #include <u.h>
> #include <libc.h>
>
> void
> exit (int code) {
> switch (code) {
> case -1:
> exits("FAILURE");
> case 0:
> exits(0);
> default:
> exits("Unknown condition");
> }
> }
>
> One could instead print("%d", code), or print("FAILURE: %d", code).
>
> Two cents, please!
printing would not make sense. neither unix nor plan 9
print exit codes.
this seems to me too complicated and not complicated enough.
on the not-complicated-enough side, to get every last program,
you would need to make exit do something like
int
exit(int r)
{
static char buf[16];
if(r == 0)
exits(0);
snprint(buf, sizeof buf, "%d", r);
exits(buf);
}
and you would need to rewrite wait to atoi(w->msg).
this would catch programs like postfix that don't treat
exit status as a boolean. (as god intended.)
but once you've done this, you're going half-way down
the ape path.
otoh, if you design in unix/plan 9 portability, it's too
much.
int
exits(char *s)
{
/* missing atexits */
exit(s && *s);
}
porting is rancid, isn't it?
- erik