Thanks for the replies, Corinna. > > A little further info. It looks like apr detects a unicode environment, > > so ultimately is calling CreateProcessW (not CreateProcessA). > > How do you pass your unicode env? Do you set the CREATE_UNICODE_ENVIRONMENT > flag?
I get a snapshot of the current environment (GetEnvironmentStrings). Then I create a new environment based on the current one, but adding two additional variables and replacing PATH with a modified version of the original PATH. Then I hand it over to apr_proc_create, which ultimately calls CreateProcessW. If you're feeling bold, the implementation is here: http://svn.apache.org/repos/asf/apr/apr/trunk/threadproc/win32/proc.c I stepped through my program in the debugger, and yes, the CREATE_UNICODE_ENVIRONMENT flag is set when apr_proc_create calls CreateProcessW. Also, I stepped through the apr code that constructs the environment map that is passed to CreateProcessW, and my PATH setting looks correct at that time. > > Also, if I pass environment variables other than PATH, they are set > > properly when the child executes. I'm even able to override other > > variables that are set already in the environment, and the new value is > > seen by the child. PATH is the only variable I can't get to work. > > Is your environment big (> 32K)? Up to 1.5.25 the environment is > fetched using GetEnvironmentStringsA, which has a bug in (at least) > Windows XP which results in a truncated environment in the child. And > it's not truncated to 32K, but much less from my testing. Something > along the lines of sizeof (child_env) == sizeof (parent_env) % 32K. Nope, I just tallied up the size: 1486 bytes total. > Other than that, I have no idea. PATH is taken from the parent like > any other env var. Are you *sure* there's not some bug in your app? Well, you never know, but I definitely try to see if it's my fault before wasting anyone else's time. To me, the key seems to be that running a native windows app as the child works fine -- it receives the PATH without any problem. It's only running a cygwin child process where the PATH is unchanged (even though 2 additional env vars other than PATH get set properly). This is the reason I'm asking on the cygwin list, and not the apr list. Obviously PATH is special to cygwin, because it has to transform the Windows representation into a Unix-like representation. I agree with you that it *should* be pulled in like any other variable, but I'm not familiar with cygwin's under-the-hood workings. This problem has me completely at a loss... Thanks again, Mike -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/