ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2000/07/16/01:19:39

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
Message-ID: <006501bfeee6$28cfd0a0$f7c723cb@lifelesswks>
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
To: <cygwin-apps AT sourceware DOT cygnus DOT com>
Cc: <cgf AT sources DOT redhat 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>
Subject: Re: two questions
Date: Sun, 16 Jul 2000 15:24:37 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700

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);
}

some tests with this:
installed as \usr\local\pathtest\pathtest.exe
(c:\cygwin\usr\local\pathtest\pathtest.exe)
From explorer: fails
from a shortcut: fails
from a cmd.exe prompt (current dir): works
from a cmd.exe prompt (as \cygwin\usr\local\pathtest\pathtest): fails
from a cmd.exe prompt (as c:\cygwin\usr\local\pathtest\pathtest): stackdump
from a cmd.exe prompt (as ..\pathtest): works
from bash (/cygdrive/c/cygwin/usr/local/pathtest/pathtest): works
from bash(./pathtest): works
from bash(/pathtest): works
from bash(/usr/local/pathtest/pathtest): works

Rob


----- Original Message -----
From: "Chris Faylor" <cgf AT cygnus DOT com>
To: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
Cc: "cygapp" <cygwin-apps AT sourceware DOT cygnus DOT com>
Sent: Sunday, July 16, 2000 2:38 PM
Subject: Re: two questions


> On Sun, Jul 16, 2000 at 02:26:50PM +1000, Robert Collins wrote:
> >Sorry, I should explain more
> >
> >exec("C:/cygwin/usr/local/program.exe") fails
> >exec("C:\\cygwin\usr\local\program.exe") works (\\ c-style escaped)
> >
> >and program.exe receives the first format from start|run, and from
> >shortcuts, or double-clicking on a program. So having a program that
calls
> >exec based in it's own path will need an library call equivalent to
> >cygpath -u (which looks to be cygwin_conv_to_posix_path(name,
> >convertedname), or for argv[0] to be a little more consistent.
>
> 'exec' is not a cygwin function.  Maybe this function is having problems
> with the path that you are specifying above.
>
> The 'exec[lv]*' family of functions should (and as far as I can tell,
> do) operate correctly with any valid windows or cygwin path.
>
> The short program below illustrates this:
>
> #include <stdio.h>
>
> int
> main (int argc, char **argv)
> {
>   fprintf (stderr, "argv[0] '%s', argv[1] '%s'\n", argv[0], argv[1]);
>   sleep(10);
>   execl (argv[1], argv + 2);
> }
>
> When I run this from Start->Run I notice that argv[0] has quotes around
> it, unlike what happens when running from the command shell.  Cygwin was
> preserving the quotes and that thwarts its later attempt to translate
> the windows path version of argv[0] into a posix path.  I've checked in
> a change to cygwin to cause it to strip the quotes from argv[0].
>
> So, I'm not sure why you are having problems running the
> c:/cygwin/usr/local/program.exe.  It works for me, and I would expect
> that it would.
>
> cgf
>
> >I've put cygwin_conv_to_posix_path in the program I'm working on, All i'm
> >saying is that a longer term solution might be to put something in the
> >startup code..
> >
> >Rob
> >
> >
> >----- Original Message -----
> >From: "Chris Faylor" <cgf AT cygnus DOT com>
> >To: "cygapp" <cygwin-apps AT sourceware DOT cygnus DOT com>
> >Sent: Sunday, July 16, 2000 1:45 PM
> >Subject: Re: two questions
> >
> >
> >> On Sun, Jul 16, 2000 at 01:45:56PM +1000, Robert Collins wrote:
> >> >1)Start|run, c:\cygwin\usr\local\program.exe
> >> >2)start|run, cmd (running win2k). then (from any drive)
> >> >"c:\cygwin\usr\local\program.exe"
> >> >
> >> >in 1, argv[0] is C:/cygwin/usr/local/program.exe
> >> >in 2, argv[0] is /usr/local/program.exe
> >> >
> >> >Note that bash was not the shell in 2! I'm quite happy to code around
> >this
> >> >myself, but if someone wanted to provide a pointer as to where I
should
> >> >place it I'm happy to code around it for cygwin..
> >> >
> >> >The reason it's a issue, is that I want to call
> >exec(argv[0],newswitches),
> >> >which the above behaviour scuttles..
> >>
> >> Why?
> >>
> >> cgf
> >>
>
> --
> cgf AT cygnus DOT com                        Cygnus Solutions, a Red Hat company
> http://sourceware.cygnus.com/         http://www.redhat.com/
>

- Raw text -


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