Date: Sun, 17 May 2015 18:56:30 +0200 From: Polytropon <freebsd@edvax.de> To: Ian Smith <smithi@nimnet.asn.au> Cc: freebsd-questions@freebsd.org Subject: Re: Strange return codes from old but good C program Message-ID: <20150517185630.2f291a77.freebsd@edvax.de> In-Reply-To: <20150517232103.V69409@sola.nimnet.asn.au> References: <20150517204503.V69409@sola.nimnet.asn.au> <20150517124223.GA82704@ozzmosis.com> <20150517232103.V69409@sola.nimnet.asn.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 18 May 2015 02:43:06 +1000 (EST), Ian Smith wrote: > Instead of fixing the declaration and adding return 0, would exit(N) do? That would be possible, see "man 3 exit" for details. To signal a normal program termination, use exit(0); and for errors, exit(1); When return 0; is encountered within main(), it will generate exit code via exit() and _exit() in the same way as if you'd just call exit(). The main() function is nothing special - every non-void function returns something. :-) You could explicitely add the (int) return type for the main() function; typical forms are: int main(void) ---> doesn't access command line parameters int main(int argc, char *argv[]) ---> accesses them This is (almost) equivalent to the K&R form: main(argc, argv) int argc; char **argv; which you probably have there somewhere. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150517185630.2f291a77.freebsd>