From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Douglas A. Gwyn" Message-ID: <3AE840B1.17EF07D7@arl.army.mil> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <20010423110853.3397219A61@mail.cse.psu.edu>, <006a01c0ccb7$5990b0b0$95b9c6d4@SOMA> Subject: Re: [9fans] the declaration of main() Date: Thu, 26 Apr 2001 16:05:15 +0000 Topicbox-Message-UUID: 90b5de04-eac9-11e9-9e20-41e7f4b1d025 Boyd Roberts wrote: > yep, IIRC, sounds like the 7th ed /lib/crt0.s which eventually > called _exit() [the syscall]. exit() was a library function > which did the above and then called _exit(). I think there was a linker trick (similar to the floating-point trick) to get the appropriate runtime startup behavior depending on whether stdio functions had been invoked or not; at least, when I tried the experiment on 7th Ed. UNIX at the time I posted (to make sure I remembered correctly), the flushing version of exit() got invoked from the startup function. Note that in PDP-11 UNIX C, C externs have an underscore prefixed to them at the linker level; so _exit in assembler corresponds to exit() in C. There is also _exit() in C, i.e. __exit in assembler, which is the plain system call you described, but from assembler one would not call that extern function but would rather use a "sys" (TRAP) instruction with the proper subcode to select the exit syscall. There were (optional) assembler macros for the syscall subcodes.