From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <90d40644058566409e8dd75c49fe716f@quanstro.net> To: lucio@proxima.alt.za, 9fans@9fans.net From: erik quanstrom Date: Fri, 30 Jan 2009 11:21:08 -0500 In-Reply-To: <42aa45f7d293eb1405d891253a687a65@proxima.alt.za> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Ogg/Vorbis ported Topicbox-Message-UUID: 8f822334-ead4-11e9-9d60-3106f5b1d025 >> 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 > #include > > 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