From owner-freebsd-questions@FreeBSD.ORG Sun May 17 16:56:41 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0B0A03CC for ; Sun, 17 May 2015 16:56:41 +0000 (UTC) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C21B814AB for ; Sun, 17 May 2015 16:56:40 +0000 (UTC) Received: from r56.edvax.de (port-92-195-33-186.dynamic.qsc.de [92.195.33.186]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id 0251524CCA; Sun, 17 May 2015 18:56:30 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id t4HGuUtg005108; Sun, 17 May 2015 18:56:30 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sun, 17 May 2015 18:56:30 +0200 From: Polytropon To: Ian Smith 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> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2015 16:56:41 -0000 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, ...