Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 May 2013 06:32:59 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        freebsd-ports@freebsd.org
Subject:   Re: Proper way to access executable's "environment"?
Message-ID:  <20130527133259.GF1334@albert.catwhisker.org>
In-Reply-To: <20130527054313.372869c1@X220.ovitrap.com>
References:  <20130526172015.GA1334@albert.catwhisker.org> <20130527054313.372869c1@X220.ovitrap.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <stdlib.h>" 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 <stdlib.h>" (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 <stdlib.h>" 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130527133259.GF1334>