COHERENT manpages
This page displays the COHERENT manpage for main() [Introduce program's main function].
List of available manpages
Index
main() -- C Language Introduce program's main function A C program consists of a set of functions, one of which must be called main(). This function is called from the runtime startup routine after the runtime environment has been initialized. Programs can terminate in one of two ways. The easiest is simply to have the main() routine return(). Control returns to the runtime startup; it closes all open file streams and otherwise cleans up, and then returns control to the operating system, passing it the value returned by main() as exit status. In some situations (errors, for example), it may be necessary to stop a program, and you may not want to return to main(). Here, you can use the library function exit(); it cleans up the debris left by the broken program and returns control directly to the operating system. The system call _exit() quickly returns control to the operating system without performing any cleanup. This routine should be used with care, because bypassing the cleanup will leave files open and buffers of data in memory. Programs compiled by COHERENT return to the program that called them; if they return from main() with a value or call exit() with a value (e.g., EXIT_SUCCESS or EXIT_FAILURE), main() returns that value to the program that invoked it (e.g., the shell). Programs that invoke other programs through the function system() check the returned value to see if these secondary programs terminated successfully. If you exit from main() without explicitly returning a value (e.g., by just letting main() simply conclude, or by invoking exit() without a return status, or by invoking return without a return value), main() returns whatever random value happens to have been in the register EAX. See Also _exit(), argc, argv, C language, envp, exit(), EXIT_FAILURE, EXIT_SUCCESS ANSI Standard, §5.1.2.2.1 POSIX Standard, §3.1.2.2