From owner-freebsd-doc@FreeBSD.ORG Mon Feb 11 11:59:20 2013 Return-Path: Delivered-To: freebsd-doc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D31424EF for ; Mon, 11 Feb 2013 11:59:20 +0000 (UTC) (envelope-from roam@ringlet.net) Received: from nimbus.fccf.net (nimbus.fccf.net [77.77.144.35]) by mx1.freebsd.org (Postfix) with ESMTP id 6E3871AA for ; Mon, 11 Feb 2013 11:59:20 +0000 (UTC) Received: from straylight.m.ringlet.net (unknown [78.90.13.150]) by nimbus.fccf.net (Postfix) with ESMTPSA id 05CF8950 for ; Mon, 11 Feb 2013 13:59:18 +0200 (EET) Received: from roam (uid 1000) (envelope-from roam@ringlet.net) id dae02a by straylight.m.ringlet.net (DragonFly Mail Agent); Mon, 11 Feb 2013 13:59:17 +0200 Date: Mon, 11 Feb 2013 13:59:17 +0200 From: Peter Pentchev To: Erich Dollansky Subject: Re: missing information in man 3 system Message-ID: <20130211115917.GA5786@straylight.m.ringlet.net> Mail-Followup-To: Erich Dollansky , freebsd-doc@freebsd.org References: <20130211120438.730ce5d3@X220.ovitrap.com> <20130211094557.GB5801@straylight.m.ringlet.net> <20130211182757.475efca2@X220.ovitrap.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline In-Reply-To: <20130211182757.475efca2@X220.ovitrap.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-doc@freebsd.org X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Feb 2013 11:59:20 -0000 --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 11, 2013 at 06:27:57PM +0700, Erich Dollansky wrote: > Hi, >=20 > On Mon, 11 Feb 2013 11:45:57 +0200 > Peter Pentchev wrote: >=20 > > On Mon, Feb 11, 2013 at 12:04:38PM +0700, Erich Dollansky wrote: > > >=20 > > > Or did I simply miss something? > >=20 > > Yes, this is indeed the intended behavior of system(3) - it does say >=20 > ok. This is good. >=20 > Ah, this is from the description section. Which I did not read. >=20 > >=20 > > if (WIFEXITED(code)) { > > printf("The program exited with code %d\n", > > WEXITSTATUS(code)); >=20 > So, this is what I need. Actually you need the whole set of tests, not just the WIFEXITED case, since the program you've ran through system() may have been killed by a signal or something. > > Yes, it may seem a bit convoluted at first glance, but it is indeed > > necessary for the purpose of providing all the information in a single > > return value. Don't worry, this is something that everyone stumbles > > into when making their first steps in system programming :) (pun > > unintended ;) >=20 > This comes then from the good-old-16-bit-days of Unix. I was more > confused by the fact that my memory was right but I could not find the > description under RETURN VALUES. That=20 > >=20 > > Hope that helps! >=20 > Yes, of course. Glad to have been of assistance! G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org p.penchev@storpool.com PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 If there were no counterfactuals, this sentence would not have been paradox= ical. --opJtzjQTFsWo+cga Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCAAGBQJRGN0QAAoJEGUe77AlJ98TNcoP/1P9N1k/J+Ux9AQGr7aj2QXj 7dl+kzSciEoAdBCLe1k/LFv+3pRzHc/fytz2xB7h9CTVRGA76UCjXJ6PTiShFMJd tOYoOfsbAfGT8/XBzD2D2C+Xop12gb62N6iwKwefkIa/Y7LpcJrGLl2r2hf6Zfoa GMsw445ZvstDDl3iu+5F8mMsXiRMGiOawcEbtw8LJFijF2Rf/vUAV+h8NLJlVb1W DnVDZkT4J7GUSULJLSlDZgUFcV2Cxki7GgKOt+BHCbguo4Yck7p2kzIU3UqwTmcs qrdAD1jdcqF9+PDqvA6Ad3EC7gFTUv2n25QVHHFwZVYDTAAevhq0JkamcKPb3t8e sMxayQmjBnMIIC73+lWn+anUazOy2xjIignI+pXf5g0ma2X9Jxrbo+2JB17Gb5Jv B1X9JTPIx19OrXzdscTVSBm13VP0JTDiax4EVFlefkvLXDRnRpt1nZfwHQt8KIPg yEIk1E4KgOR3IsEv5MVYrgIXTqkF0LM0bpF/2jeGS8zXbhmXmG/B8o843p+/wzSl Q8X9rnb7lS96vYp7PwVpxNbo5viWmoQ3NKNYhLcJLKcYzZC8EAXHZVylHxx/zMkK DfM/d1oWO0LImcAu66nmHIEKhrNcwY3atVwKoS/QT5+2CTydApQOVrZZw1R7Eixt Dy4Vv5wJxgUEPInLCV5v =iBM4 -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--