1.7.9: g_spawn with envp set doesn't see my envp unless it's setting PATH

Fischer, Matthew L matt.fischer@hp.com
Tue Jun 7 21:56:00 GMT 2011


I have code that calls g_spawn_sync and sets an environment variable.  The program that I am spawning simply dumps out the environment and exits.  I found some odd behavior when running this test app on Cygwin, if I set any random variable, like "HELLO=world" it is not passed to the child.  However, if I set PATH, I get it set along with 2 other variables.  Attached is my test code that demonstrates the issue.

Environ.c - child program that dumps the environment
Gspawn_env_test.cpp - program that spawns environ.c and reads the output
Make - simple shell script that builds the test apps

Cygwin 1.7.9 results:

$ ./gspawn_env_test.exe
** (process:5080): DEBUG: Calling my_environ with envp set to HELLO=world
** (process:5080): DEBUG: result:

** (process:5080): DEBUG: ------------------------------------
** (process:5080): DEBUG: Calling my_environ with envp set to PATH=/usr/bin
** (process:5080): DEBUG: result:
PATH=/usr/bin
SYSTEMROOT=C:\Windows
WINDIR=C:\Windows

** (process:5080): DEBUG: ------------------------------------

Ubuntu 10.04 results:

[mfisch@toaster ~/gspawn_issue]$ ./gspawn_env_test
** (process:29580): DEBUG: Calling my_environ with envp set to HELLO=world
** (process:29580): DEBUG: result:
HELLO=world

** (process:29580): DEBUG: ------------------------------------
** (process:29580): DEBUG: Calling my_environ with envp set to PATH=/usr/bin
** (process:29580): DEBUG: result:
PATH=/usr/bin

** (process:29580): DEBUG: ------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 32373 bytes
Desc: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110607/8b577248/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: environ.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110607/8b577248/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gspawn_env_test.cpp
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110607/8b577248/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make
Type: application/octet-stream
Size: 124 bytes
Desc: make
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110607/8b577248/attachment-0001.obj>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list