delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2000/07/16/01:34:05

Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-apps-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/lists.html#faqs>
Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com
From: Chris Faylor <cgf AT cygnus DOT com>
Date: Sun, 16 Jul 2000 01:33:41 -0400
To: cygwin-apps AT sourceware DOT cygnus DOT com
Subject: Re: two questions
Message-ID: <20000716013341.A9284@cygnus.com>
Reply-To: cygwin-apps AT sources DOT redhat DOT com
Mail-Followup-To: cygwin-apps AT sourceware DOT cygnus DOT com
References: <004801bfeed8$5a75f610$f7c723cb AT lifelesswks> <20000715234510 DOT A8476 AT cygnus DOT com> <005c01bfeede$10604c00$f7c723cb AT lifelesswks> <20000716003824 DOT A8880 AT cygnus DOT com> <006401bfeee6$24ba9680$f7c723cb AT lifelesswks>
Mime-Version: 1.0
User-Agent: Mutt/1.2i
In-Reply-To: <006401bfeee6$24ba9680$f7c723cb@lifelesswks>; from robert.collins@itdomain.com.au on Sun, Jul 16, 2000 at 03:24:35PM +1000

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..
>
>#include <stdio.h>
>
>int
>main (int argc, char **argv)
>{
>  char *prog;
>  char passarg[]="A";
>  fprintf (stderr, "argv[0] '%s', argv[1] '%s'\n", argv[0], argv[1]);
>  prog=(char *)strdup(argv[0]);
>  if (argv[1]==NULL)
>  {
>    fprintf(stderr, "called with no args going to run '%s' with '%s'
>\n",prog,passarg);
>    sleep(5);
>    execl (prog,prog,passarg );
>    /* SHOULD NEVER REACH */
>    fprintf(stderr, "exec failed!\n");
>    sleep(10);
>    }
>  sleep(10);
>}

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
argument.

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
something like:

argv[0] '"c:\cygwin\usr\local\pathtest\pathtest"', argv[1] '(null)'
        ^^                                     ^^

The extra levels of quoting are what was screwing up cygwin.  As
I mentioned, I just checked in a patch to fix this.

cgf

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019