Path: utzoo!mnetor!uunet!husc6!bbn!rochester!ur-tut!sunybcs!boulder!hao!ames!elroy!cit-vax!cit-vlsi!wen-king From: wen-king@cit-vlsi.Caltech.Edu (Wen-King Su) Newsgroups: comp.lang.c Subject: exit(-1) does not work ??? Message-ID: <5262@cit-vax.Caltech.Edu> Date: 21 Jan 88 19:03:21 GMT References: <6935@brl-smoke.ARPA> <7208@ki4pv.uucp> <334@splut.UUCP> <7292@ki4pv.uucp> <555@cresswell.quintus.UUCP> Sender: news@cit-vax.Caltech.Edu Reply-To: wen-king@cit-vlsi.UUCP (Wen-King Su) Organization: California Institute of Technology Lines: 34 Keywords: exit, zero In article <555@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >In article <7292@ki4pv.uucp>, tanner@ki4pv.uucp (Dr. T. Andrews) writes: I think I was the one to start this exchange about exit() in C, and my sticking to 0 and 1 because they *do* work in UNIX *and* in VMS. This seems a little strange to me so I decided to check it out. Following is a script showing that exit(-1) DOES work in UNIX. I am running it on a SUN and I am using csh. Script started on Thu Jan 21 10:19:36 1988 % cat t.c main() { exit(-1); } % t % echo $status -1 % t & [1] 5825 % [1] Exit -1 t % ^D script done on Thu Jan 21 10:20:03 1988 I agree that it is a good idea to have 0 as the universal indicator of success, but I believe application programmers should be free to use other numbers to their own advantage and OS should provide them with the maximum flexibility. The issue of portability is something each programmer has to decide for self, but it is always useful for those who had the experience to point out trouble spots and recommend solutions. /*------------------------------------------------------------------------*\ | Wen-King Su wen-king@vlsi.caltech.edu Caltech Corp of Cosmic Engineers | \*------------------------------------------------------------------------*/