1.3.4: error in inheriting new PATH environment form WIN32 executable toCYGWIN executable
Heiko_Elger@arburg.com
Heiko_Elger@arburg.com
Wed Nov 7 05:33:00 GMT 2001
Hello,
I have the following problem:
If a MS WIN 32 program changes his environment PATH variable to a very long
value (over 270 characters) and than calling a CYGWIN program per system() call
the path inside the CYGWIN program is reset to NULL! If it calls a MS WIN 32
program all works fine.
We have this problem with clearmake in exporting a very long path and the shell
is the CYGWIN sh.exe.
I tried to reproduce it within a very small test.
I wrote two small programs (belwo you wil find the sourcecode):
changeenv.c --> MS WIN 32 program which change his PATH environment and calls
per system() the program "printpath"
printpath.c --> prints the PATH environment to stdout
changeenv.exe is compiled with Microsoft Visual Studio.
printpath.exe is compiled with MS Visual Studio and cygwin gcc
I hope anyone can reproduce this error and give me a hint to resolve may
problem.
Best regards
Heiko Elger
----------------------- start changeenv.c --------------------
#include <stdio.h>
#include <stdlib.h>
#define CYGWIN_SHELL "d:\\programme\\cygwin\\bin\\sh"
#define CYGWIN_PRINTPATH "d:\\msdev\\makenv\\printpath\\printpath"
#define WIN32_PRINTPATH "d:\\msdev\\makenv\\printpath\\Debug\\printpath"
char long_path[]
= "PATH=/usr/bin:/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
;
int main (int argc, char ** argv, char **env)
{
int rc=0;
char * env_path ;
if (putenv(long_path) == -1)
perror("putenv()");
env_path = getenv("PATH");
printf("NEW Path=%s\n", env_path == NULL ? "" : env_path);
if (system( CYGWIN_SHELL " -ic \"echo system CYGWIN SHELL PATH=$PATH\"") !=
0)
perror("system()");
printf("system CYGWIN printpath: "); fflush( stdout );
if (system( CYGWIN_PRINTPATH ) != 0)
perror("system()");
printf("system WIN32 printpath: "); fflush( stdout );
if (system( WIN32_PRINTPATH ) != 0)
perror("system()");
return rc;
}
----------------------- end changeenv.c --------------------
----------------------- start printpath.c --------------------
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char ** argv, char **env)
{
int rc=0;
char * env_path ;
env_path = getenv("PATH");
printf("Path=%s\n", env_path == NULL ? "" : env_path);
return rc;
}----------------------- end printpath.c --------------------
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list