Mail Archives: cygwin-apps/2000/07/16/01:34:05
On Sun, Jul 16, 2000 at 03:24:35PM +1000, Robert Collins wrote:
>This sample program demonstrates the problem. I am using execvp for my my
>code, by exec() I actually meant the exec family of calls... I'll try to be
>clearer next time..
>main (int argc, char **argv)
> char *prog;
> char passarg="A";
> fprintf (stderr, "argv '%s', argv '%s'\n", argv, argv);
> prog=(char *)strdup(argv);
> if (argv==NULL)
> fprintf(stderr, "called with no args going to run '%s' with '%s'
> execl (prog,prog,passarg );
> /* SHOULD NEVER REACH */
> fprintf(stderr, "exec failed!\n");
Both of our test programs had bugs in them. Mine would core dump if
there was more than one argument. Yours SEGVs every time for me, although
it could also just SEGV randomly, I suppose.
The reason is that execl needs to be terminated with a NULL final
Regardless, my analysis of what was going wrong is still probably
correct. You didn't report on the output of any of the test
cases but I would guess that, when run from explorer, you'd see
argv '"c:\cygwin\usr\local\pathtest\pathtest"', argv '(null)'
The extra levels of quoting are what was screwing up cygwin. As
I mentioned, I just checked in a patch to fix this.
- Raw text -