From owner-freebsd-ports@FreeBSD.ORG Mon May 27 13:33:04 2013 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DB979ADC for ; Mon, 27 May 2013 13:33:04 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from albert.catwhisker.org (m209-73.dsl.rawbw.com [198.144.209.73]) by mx1.freebsd.org (Postfix) with ESMTP id 9E117249 for ; Mon, 27 May 2013 13:33:03 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.7/8.14.7) with ESMTP id r4RDWxhf010693 for ; Mon, 27 May 2013 06:32:59 -0700 (PDT) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.7/8.14.7/Submit) id r4RDWx96010692 for freebsd-ports@freebsd.org; Mon, 27 May 2013 06:32:59 -0700 (PDT) (envelope-from david) Date: Mon, 27 May 2013 06:32:59 -0700 From: David Wolfskill To: freebsd-ports@freebsd.org Subject: Re: Proper way to access executable's "environment"? Message-ID: <20130527133259.GF1334@albert.catwhisker.org> References: <20130526172015.GA1334@albert.catwhisker.org> <20130527054313.372869c1@X220.ovitrap.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HCdXmnRlPgeNBad2" Content-Disposition: inline In-Reply-To: <20130527054313.372869c1@X220.ovitrap.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2013 13:33:04 -0000 --HCdXmnRlPgeNBad2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 27, 2013 at 05:43:13AM +0700, Erich Dollansky wrote: > ... > > piewm's twm.c declares main as: > >=20 > > int > > main(int argc, char **argv, char **environ) > > { >=20 > I use this concept since decades but with different names. Could it be > a problem of overlapping names? > ... It was pointed out to me that -- other than assigning "Environ =3D environ" -- the code in piewm's twm.c didn't actually use the values of environ or Environ. [Thanks, Stefan!] Elsewhere, there is a putenv() implementation for environments that lack it, and the code uses getenv(), as well. Doing a few more comparisons with twm.c from tvtwm and from twm itself; I have a few more observations: * tvtwm's twm.c is more recent than that of piewm: - * $XConsortium: twm.c,v 1.124 91/05/08 11:01:54 dave Exp $ + * $XConsortium: twm.c,v 1.111 90/03/23 13:23:34 jim Exp $ * twm's twm.c has a copyright block dated 2005 from Hitachi, Ltd. * Merely inserting the "#include " in piewm's twm.c appears to be a minimal effective change: Once that's done, the SIGSEGV goes away. * Neither tvtwm's nor twm's twm.c has the "#include " (and neither gets a SIGSEGV). * As Stefan pointed out, I was able to completely remove the references to both "environ" and "Environ" from piewm's twm.c; the result builds and runs without problem. * tvtwm's twm.c has these environ and Environ variables (and, as above, lacks the "#include " and doesn't get the SIGSEGV). * twm's twm.c lacks the environ and Environ variables (and main() is defined as a function that takes but 2 arguments). I suspect that I'm failing to understand at least part of what's causing the actual problem in piewm. Peace, david --=20 David H. Wolfskill david@catwhisker.org Taliban: Evil men with guns afraid of truth from a 14-year old girl. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --HCdXmnRlPgeNBad2 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iEYEARECAAYFAlGjYIoACgkQmprOCmdXAD1oCwCfZhSDZDN8iLF3hIl9nCV+/wSW 0uAAnRmbcJeNizsgkDAfl7Fnm7qYygQ9 =bhsm -----END PGP SIGNATURE----- --HCdXmnRlPgeNBad2--