Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!unm-la!unmvax!nmtsun!hydrovax From: hydrovax@nmtsun.nmt.edu (M. Warner Losh) Newsgroups: comp.lang.c Subject: Re: exit(-1) Message-ID: <1240@nmtsun.nmt.edu> Date: 22 Jan 88 01:42:49 GMT References: <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> <1179@wjvax.UUCP> <10237@mimsy.UUCP> Organization: NMT Hydrology program Lines: 54 Summary: Exit codes and interpretation In article <10237@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > In article <1225@nmtsun.nmt.edu> I write > >... The more proper VMS implementation of EXIT_STATUS should be > >SS$_NORMAL, which is (at least in 4x) defined to be 1. > > (I think it was inherited from RT-11. It was 1 in VMS 2.8.) > > >Why would you expect an operating system dependent scheme such > >as exit(0) to work on all OS's? > > Simple. Let me phrase it this way: `Why would you expect a standard > library scheme to be dependent on the O/S?' Or, `whoever said exit > was a system call?' If I remember correctly, fopen() is system dependent (you can't say fopen ("/tmp/foo", "r"), for example, and expect it to work on all operating systems. The same sort of thing is true about exit(). > Unix, by virtue of being the first system to implement the language, > is privileged: it gets to take the argument to exit() and pass it > back to the calling program. Other systems might have to convert > the argument to 0 => success, anything else => unspecified failure. The UNIX operating system does not work this way. The shells that surround it DO. What I mean is this : UNIX doesn't give a furry rat's whatever what you use for an exit status, it mearly passes it to the shell (or to make, or whatever) who then desides what to do with that number. Even the shell doesn't care what value you give it, as long as you give it something. Most people choose to use zero, cause that's what K&R say to use. Not that I'm slamming UNIX, or anything, that's just what's goin' on behind the scenes. In VMS, the exit status is more than just any arbitrary number. Each of the numbers has a perscribed meaning. The numbers are interpeted, again by the shell (to use the UNIX terminology; command interpreter to use DEC's), as meaning success or failure. Again, these exit values are useful to the shell, or shell scripts that are running (DCL command files) IN ADDITION TO THE SHELL ITSELF. There are mechanisms to allow you to say "When a warning, or anything more sever occures, then branch to this part of my DCL program". The basic argument is this: Since UNIX had it first, should all other OS's be forced to use that convention? I think not. THIS IS AN OPERATING SYSTEM DEPENDENT ISSUE, just like file names. It should be delt with in a reasonably intelligent mannor, so that ALL PARTIES involved CAN WRITE PORTABLE CODE. Isn't that what ANSI is all about????? -- bitnet: lush@nmt.csnet M. Warner Losh csnet: warner%hydrovax@nmtsun uucp: ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!hydrovax Warning: Hydrovax is both a machine, and an account, so be careful.