public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
@ 2013-07-16 17:39 Andrey Repin
  2013-07-16 18:02 ` Andrey Repin
  2013-07-17 13:36 ` Corinna Vinschen
  0 siblings, 2 replies; 17+ messages in thread
From: Andrey Repin @ 2013-07-16 17:39 UTC (permalink / raw)
  To: All

Greetings, All!

I'm trying to execute a script that was working fine until recent update.
It doesn't crash, just, for some reason, trim the last component of a path.

In a nutshell, the issue is this:

$ mkdir "/a b"
$ cd "/a b"
$ ls -l "$SYSTEMROOT/System32/notepad.exe"
(just to confirm that the file actually exists)
$ run "$SYSTEMROOT/System32/notepad.exe"
Error pops up:

---------------------------
Run.exe
---------------------------
Error: could not start C:\Programs\CygWin\a b

---------------------------
OK
---------------------------


$ cygcheck.exe -v run
Found: C:\Programs\CygWin\bin\run.exe
Found: C:\Programs\CygWin\bin\run.exe
C:\Programs\CygWin\bin\run.exe - os=4.0 img=1.0 sys=4.0
  C:\Programs\CygWin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
    "cygwin1.dll" v0.0 ts=2013-07-15 11:17
    C:\WINDOWS\system32\KERNEL32.dll - os=5.1 img=5.1 sys=4.0
      "KERNEL32.dll" v0.0 ts=2009-03-21 12:36
      C:\WINDOWS\system32\ntdll.dll - os=5.1 img=5.1 sys=4.10
        "ntdll.dll" v0.0 ts=2010-12-09 13:38
    C:\WINDOWS\system32\ntdll.dll (already done)
  C:\WINDOWS\system32\KERNEL32.dll (already done)
  C:\WINDOWS\system32\SHELL32.DLL - os=5.1 img=5.1 sys=4.10
    "SHELL32.dll" v0.0 ts=2012-06-08 14:41
    C:\WINDOWS\system32\ADVAPI32.dll - os=5.1 img=5.1 sys=4.0
      "ADVAPI32.dll" v0.0 ts=2009-02-06 11:02
      C:\WINDOWS\system32\KERNEL32.dll (already done)
      C:\WINDOWS\system32\ntdll.dll (already done)
      C:\WINDOWS\system32\RPCRT4.dll - os=5.1 img=5.1 sys=4.10
        "RPCRT4.dll" v0.0 ts=2010-08-13 14:32
        C:\WINDOWS\system32\ADVAPI32.dll (recursive)
        C:\WINDOWS\system32\KERNEL32.dll (already done)
        C:\WINDOWS\system32\ntdll.dll (already done)
        C:\WINDOWS\system32\Secur32.dll - os=5.1 img=5.1 sys=4.0
          "Secur32.dll" v0.0 ts=2009-06-24 13:10
          C:\WINDOWS\system32\ADVAPI32.dll (recursive)
          C:\WINDOWS\system32\KERNEL32.dll (already done)
          C:\WINDOWS\system32\ntdll.dll (already done)
    C:\WINDOWS\system32\GDI32.dll - os=5.1 img=5.1 sys=4.10
      "GDI32.dll" v0.0 ts=2008-10-22 17:52
      C:\WINDOWS\system32\KERNEL32.dll (already done)
      C:\WINDOWS\system32\ntdll.dll (already done)
      C:\WINDOWS\system32\USER32.dll - os=5.1 img=5.1 sys=4.0
        "USER32.dll" v0.0 ts=2008-04-13 20:22
        C:\WINDOWS\system32\GDI32.dll (recursive)
        C:\WINDOWS\system32\KERNEL32.dll (already done)
        C:\WINDOWS\system32\ntdll.dll (already done)
    C:\WINDOWS\system32\KERNEL32.dll (already done)
    C:\WINDOWS\system32\msvcrt.dll - os=5.1 img=5.1 sys=4.0
      "msvcrt.dll" v0.0 ts=2008-04-13 17:41
      C:\WINDOWS\system32\KERNEL32.dll (already done)
      C:\WINDOWS\system32\ntdll.dll (already done)
    C:\WINDOWS\system32\ntdll.dll (already done)
    C:\WINDOWS\system32\RPCRT4.dll (already done)
    C:\WINDOWS\system32\SHLWAPI.dll - os=5.1 img=5.1 sys=4.0
      "SHLWAPI.dll" v0.0 ts=2009-12-07 13:39
      C:\WINDOWS\system32\ADVAPI32.dll (already done)
      C:\WINDOWS\system32\GDI32.dll (already done)
      C:\WINDOWS\system32\KERNEL32.dll (already done)
      C:\WINDOWS\system32\msvcrt.dll (already done)
      C:\WINDOWS\system32\USER32.dll (already done)
    C:\WINDOWS\system32\USER32.dll (already done)
  C:\WINDOWS\system32\USER32.dll (already done)

$ cygcheck.exe -f /bin/run.exe
run-1.2.0-1

$ cygcheck.exe -c run
Cygwin Package Information
Package              Version        Status
run                  1.2.0-1        OK


-- 
WBR,
Andrey Repin (anrdaemon@freemail.ru) 16.07.2013, <20:12>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-16 17:39 Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21) Andrey Repin
@ 2013-07-16 18:02 ` Andrey Repin
  2013-07-17 13:36 ` Corinna Vinschen
  1 sibling, 0 replies; 17+ messages in thread
From: Andrey Repin @ 2013-07-16 18:02 UTC (permalink / raw)
  To: All

Greetings, All!

> I'm trying to execute a script that was working fine until recent update.
> It doesn't crash, just, for some reason, trim the last component of a path.

Sorry, it doesn't "trim" anything. The line was from earlier guess, before I
started to run more tests.

> In a nutshell, the issue is this:

> $ mkdir "/a b"
> $ cd "/a b"
> $ ls -l "$SYSTEMROOT/System32/notepad.exe"
> (just to confirm that the file actually exists)
> $ run "$SYSTEMROOT/System32/notepad.exe"
> Error pops up:

> ---------------------------
> Run.exe
> ---------------------------
> Error: could not start C:\Programs\CygWin\a b

> ---------------------------
> OK
> ---------------------------


> $ cygcheck.exe -f /bin/run.exe
> run-1.2.0-1

> $ cygcheck.exe -c run
> Cygwin Package Information
> Package              Version        Status
> run                  1.2.0-1        OK

Reverting to previous version of package doesn't help.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 16.07.2013, <21:02>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-16 17:39 Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21) Andrey Repin
  2013-07-16 18:02 ` Andrey Repin
@ 2013-07-17 13:36 ` Corinna Vinschen
  2013-07-17 14:02   ` Charles Wilson
  2013-07-17 14:10   ` Andrey Repin
  1 sibling, 2 replies; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 13:36 UTC (permalink / raw)
  To: cygwin

On Jul 16 20:29, Andrey Repin wrote:
> Greetings, All!
> 
> I'm trying to execute a script that was working fine until recent update.
> It doesn't crash, just, for some reason, trim the last component of a path.
> 
> In a nutshell, the issue is this:
> 
> $ mkdir "/a b"
> $ cd "/a b"
> $ ls -l "$SYSTEMROOT/System32/notepad.exe"
> (just to confirm that the file actually exists)
> $ run "$SYSTEMROOT/System32/notepad.exe"
> Error pops up:

This never works, even in any other directory.  It's the same problem
which disallows checkX to work, as reported in
http://cygwin.com/ml/cygwin/2013-07/msg00326.html

The cause is an optimization when calling cygwin executables.  So far,
Cygwin executables got their arguments via mmeory copy as well as via
the single-line cmdline argument of CreateProcess.  We removed the
latter since it was never meant to work that way in the first place.

Unfortunately it turns out that run/run2/checkX are Cygwin executables
which don't have a main routine, but rather a WinMain routine.  The
latter has a single cmdline argument, which is generated via
GetCommandLine().  But since Cygwin executables get no single-line
command line anymore, this stopped working.


Stay tuned,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 13:36 ` Corinna Vinschen
@ 2013-07-17 14:02   ` Charles Wilson
  2013-07-17 14:05     ` Corinna Vinschen
  2013-07-17 14:10   ` Andrey Repin
  1 sibling, 1 reply; 17+ messages in thread
From: Charles Wilson @ 2013-07-17 14:02 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 8:59 AM, Corinna Vinschen wrote:
> This never works, even in any other directory.  It's the same problem
> which disallows checkX to work, as reported in
> http://cygwin.com/ml/cygwin/2013-07/msg00326.html
>
> The cause is an optimization when calling cygwin executables.  So far,
> Cygwin executables got their arguments via mmeory copy as well as via
> the single-line cmdline argument of CreateProcess.  We removed the
> latter since it was never meant to work that way in the first place.
>
> Unfortunately it turns out that run/run2/checkX are Cygwin executables
> which don't have a main routine, but rather a WinMain routine.  The
> latter has a single cmdline argument, which is generated via
> GetCommandLine().  But since Cygwin executables get no single-line
> command line anymore, this stopped working.

This is a pretty unusual situation. I don't know of any other tool -- 
except perhaps the old frankenstein half-cygwin-half-win32 tclsh.exe and 
wish.exe -- that does this, outside of run, run2, and checkX.  All of 
which are cygwin-specific (or, at least, cygwin + mingw specific).

Could we add a new cygwin_internal routine that triggers the allocation, 
creation and return of a suitable single-line command?  Then run & 
friends could do (pseudo-code):

WinMain()
{
    LPCSTR s = GetCommandLine()
#ifdef __CYGWIN__
    if s empty
       s = (LPCSTR) cygwin_internal(CW_WIN32_COMMAND_LINE)
#endif

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:02   ` Charles Wilson
@ 2013-07-17 14:05     ` Corinna Vinschen
  2013-07-17 14:09       ` Charles Wilson
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 14:05 UTC (permalink / raw)
  To: cygwin

On Jul 17 09:36, Charles Wilson wrote:
> On 7/17/2013 8:59 AM, Corinna Vinschen wrote:
> >This never works, even in any other directory.  It's the same problem
> >which disallows checkX to work, as reported in
> >http://cygwin.com/ml/cygwin/2013-07/msg00326.html
> >
> >The cause is an optimization when calling cygwin executables.  So far,
> >Cygwin executables got their arguments via mmeory copy as well as via
> >the single-line cmdline argument of CreateProcess.  We removed the
> >latter since it was never meant to work that way in the first place.
> >
> >Unfortunately it turns out that run/run2/checkX are Cygwin executables
> >which don't have a main routine, but rather a WinMain routine.  The
> >latter has a single cmdline argument, which is generated via
> >GetCommandLine().  But since Cygwin executables get no single-line
> >command line anymore, this stopped working.
> 
> This is a pretty unusual situation. I don't know of any other tool
> -- except perhaps the old frankenstein half-cygwin-half-win32
> tclsh.exe and wish.exe -- that does this, outside of run, run2, and
> checkX.  All of which are cygwin-specific (or, at least, cygwin +
> mingw specific).
> 
> Could we add a new cygwin_internal routine that triggers the
> allocation, creation and return of a suitable single-line command?
> Then run & friends could do (pseudo-code):
> 
> WinMain()
> {
>    LPCSTR s = GetCommandLine()
> #ifdef __CYGWIN__
>    if s empty
>       s = (LPCSTR) cygwin_internal(CW_WIN32_COMMAND_LINE)
> #endif

That should be unnecessary.  The culprit here is the default main
routine in cygwin's libcmain.c, which calls WinMain if the executable
doesn't provide its own main.

It doesn't construct the single-line commandline from argv, but rather
it calls GetCommandLinė.  This, obviously, creates an empty command line
for WinMain.

So, the actual fix is to change libcmain's main() routine to create
WinMain's cmdline arg from argc/argv.

However, either way, you will have to rebuild run/run2 for both
architectures since libcmain.c is linked statically to the executable.

So, if we do it this way, we should probably upload a new Cygwin DLL
with the patched libcmain ASAP, so you can rebuild against the new
libcmain.  Or, actually it would be better you would test this as soon
as we made the patch, *before* releasing a new Cygwin DLL.

Anyway, if we do it that way, let's hope no other tool is doing the
same...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:05     ` Corinna Vinschen
@ 2013-07-17 14:09       ` Charles Wilson
  2013-07-17 14:33         ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: Charles Wilson @ 2013-07-17 14:09 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 9:45 AM, Corinna Vinschen wrote:
> On Jul 17 09:36, Charles Wilson wrote:
>> Could we add a new cygwin_internal routine that triggers the
>> allocation, creation and return of a suitable single-line command?
>> Then run & friends could do (pseudo-code):

> That should be unnecessary.  The culprit here is the default main
> routine in cygwin's libcmain.c, which calls WinMain if the executable
> doesn't provide its own main.
>
> It doesn't construct the single-line commandline from argv, but rather
> it calls GetCommandLinė.  This, obviously, creates an empty command line
> for WinMain.
>
> So, the actual fix is to change libcmain's main() routine to create
> WinMain's cmdline arg from argc/argv.

Ack.

> However, either way, you will have to rebuild run/run2 for both
> architectures since libcmain.c is linked statically to the executable.

Right.

> So, if we do it this way, we should probably upload a new Cygwin DLL
> with the patched libcmain ASAP, so you can rebuild against the new
> libcmain.  Or, actually it would be better you would test this as soon
> as we made the patch, *before* releasing a new Cygwin DLL.

NP. Both of those packages have been recently rebuilt, so they are "up 
to date" with regard to the (relatively recent) w32api and cygport 
improvements; it's just a simply rebuild with no other changes.

> Anyway, if we do it that way, let's hope no other tool is doing the
> same...

Seems pretty unlikely to me. Most cygwin apps derive from a unix or 
traditional programming model heritage, and use main(). Very few would 
seem to derive from a Win32 heritage with WinMain() (why bother? just 
run the native program instead of porting a windows app to cygwin).

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 13:36 ` Corinna Vinschen
  2013-07-17 14:02   ` Charles Wilson
@ 2013-07-17 14:10   ` Andrey Repin
  2013-07-17 14:20     ` Corinna Vinschen
  1 sibling, 1 reply; 17+ messages in thread
From: Andrey Repin @ 2013-07-17 14:10 UTC (permalink / raw)
  To: Corinna Vinschen

Greetings, Corinna Vinschen!

> On Jul 16 20:29, Andrey Repin wrote:
>> Greetings, All!
>> 
>> I'm trying to execute a script that was working fine until recent update.
>> It doesn't crash, just, for some reason, trim the last component of a path.
>> 
>> In a nutshell, the issue is this:
>> 
>> $ mkdir "/a b"
>> $ cd "/a b"
>> $ ls -l "$SYSTEMROOT/System32/notepad.exe"
>> (just to confirm that the file actually exists)
>> $ run "$SYSTEMROOT/System32/notepad.exe"
>> Error pops up:

> This never works, even in any other directory.  It's the same problem
> which disallows checkX to work, as reported in
> http://cygwin.com/ml/cygwin/2013-07/msg00326.html

Now, it doesn't work >.> Worked before, while I was running tests.
What magic is dat?

> The cause is an optimization when calling cygwin executables.  So far,
> Cygwin executables got their arguments via mmeory copy as well as via
> the single-line cmdline argument of CreateProcess.  We removed the
> latter since it was never meant to work that way in the first place.

> Unfortunately it turns out that run/run2/checkX are Cygwin executables
> which don't have a main routine, but rather a WinMain routine.  The
> latter has a single cmdline argument, which is generated via
> GetCommandLine().  But since Cygwin executables get no single-line
> command line anymore, this stopped working.


> Stay tuned,

I am. In the meantime, I had to use
cmd /C start "" "$( cygpath -alm "$CWD/..." )"


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 17.07.2013, <17:52>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:10   ` Andrey Repin
@ 2013-07-17 14:20     ` Corinna Vinschen
  2013-07-17 20:45       ` Christopher Faylor
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 14:20 UTC (permalink / raw)
  To: cygwin

On Jul 17 17:54, Andrey Repin wrote:
> Greetings, Corinna Vinschen!
> 
> > On Jul 16 20:29, Andrey Repin wrote:
> >> Greetings, All!
> >> 
> >> I'm trying to execute a script that was working fine until recent update.
> >> It doesn't crash, just, for some reason, trim the last component of a path.
> >> 
> >> In a nutshell, the issue is this:
> >> 
> >> $ mkdir "/a b"
> >> $ cd "/a b"
> >> $ ls -l "$SYSTEMROOT/System32/notepad.exe"
> >> (just to confirm that the file actually exists)
> >> $ run "$SYSTEMROOT/System32/notepad.exe"
> >> Error pops up:
> 
> > This never works, even in any other directory.  It's the same problem
> > which disallows checkX to work, as reported in
> > http://cygwin.com/ml/cygwin/2013-07/msg00326.html
> 
> Now, it doesn't work >.> Worked before, while I was running tests.
> What magic is dat?

None.  Never works means, it's independent of the dir name of the CWD.
It just never works.  In 1.7.21.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:09       ` Charles Wilson
@ 2013-07-17 14:33         ` Corinna Vinschen
  2013-07-17 14:54           ` Charles Wilson
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 14:33 UTC (permalink / raw)
  To: cygwin

On Jul 17 10:02, Charles Wilson wrote:
> On 7/17/2013 9:45 AM, Corinna Vinschen wrote:
> >On Jul 17 09:36, Charles Wilson wrote:
> >>Could we add a new cygwin_internal routine that triggers the
> >>allocation, creation and return of a suitable single-line command?
> >>Then run & friends could do (pseudo-code):
> 
> >That should be unnecessary.  The culprit here is the default main
> >routine in cygwin's libcmain.c, which calls WinMain if the executable
> >doesn't provide its own main.
> >
> >It doesn't construct the single-line commandline from argv, but rather
> >it calls GetCommandLinė.  This, obviously, creates an empty command line
> >for WinMain.
> >
> >So, the actual fix is to change libcmain's main() routine to create
> >WinMain's cmdline arg from argc/argv.
> 
> Ack.
> 
> >However, either way, you will have to rebuild run/run2 for both
> >architectures since libcmain.c is linked statically to the executable.
> 
> Right.
> 
> >So, if we do it this way, we should probably upload a new Cygwin DLL
> >with the patched libcmain ASAP, so you can rebuild against the new
> >libcmain.  Or, actually it would be better you would test this as soon
> >as we made the patch, *before* releasing a new Cygwin DLL.
> 
> NP. Both of those packages have been recently rebuilt, so they are
> "up to date" with regard to the (relatively recent) w32api and
> cygport improvements; it's just a simply rebuild with no other
> changes.
> 
> >Anyway, if we do it that way, let's hope no other tool is doing the
> >same...
> 
> Seems pretty unlikely to me. Most cygwin apps derive from a unix or
> traditional programming model heritage, and use main(). Very few
> would seem to derive from a Win32 heritage with WinMain() (why
> bother? just run the native program instead of porting a windows app
> to cygwin).

Uhm.  In that case, if ew *really* think your tools are the only
affected ones, Why do we bother to fix libcmain.c?  Can't you then
simply provide your own main() in case of building for Cygwin?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:33         ` Corinna Vinschen
@ 2013-07-17 14:54           ` Charles Wilson
  2013-07-17 15:39             ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: Charles Wilson @ 2013-07-17 14:54 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 10:10 AM, Corinna Vinschen wrote:
> Uhm.  In that case, if ew *really* think your tools are the only
> affected ones, Why do we bother to fix libcmain.c?  Can't you then
> simply provide your own main() in case of building for Cygwin?

Perhaps, but I'm not sure of the ramifications. I think if you have a 
main() then you're going to get STD_HANDLES. Plus there's the whole 
concern about launching run[2].exe itself without a cmdbox, when it is 
used as a shortcut target.

This whole entrypoint thing is tied up in that, or at least it used to 
be.  Now, that may ONLY apply to the mingw[64]-compiled version, in 
which case I could do a

#ifdef __CYGWIN__
int main (int argc, char** argv)
{
    return realmain(argc, argv);
}
#endif
and avoid the -e WinMain@16 link argument. (Except I think I arrange to 
only do -e WinMain@16 on mingw...hmm...)

If you look closely at WinMain, it basically parses the result from 
GetCommandLine() into argc,argv, and then delegates. The only 
conceivable reason to do that, rather than just have a main(), was if 
you NEED to use WinMain() as the entry point for some other reason. Like 
ensuring that you "work" when compiled as a non-console app and don't 
pop up a dosbox...

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:54           ` Charles Wilson
@ 2013-07-17 15:39             ` Corinna Vinschen
  2013-07-17 15:52               ` Charles Wilson
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 15:39 UTC (permalink / raw)
  To: cygwin

On Jul 17 10:20, Charles Wilson wrote:
> On 7/17/2013 10:10 AM, Corinna Vinschen wrote:
> >Uhm.  In that case, if ew *really* think your tools are the only
> >affected ones, Why do we bother to fix libcmain.c?  Can't you then
> >simply provide your own main() in case of building for Cygwin?
> 
> Perhaps, but I'm not sure of the ramifications. I think if you have
> a main() then you're going to get STD_HANDLES. Plus there's the
> whole concern about launching run[2].exe itself without a cmdbox,
> when it is used as a shortcut target.

In that case, the application gets the command line via GetCommandLine,
which in turn is converted to argc,argv by the Cygwin DLL ebfore calling
main.

> This whole entrypoint thing is tied up in that, or at least it used
> to be.  Now, that may ONLY apply to the mingw[64]-compiled version,
> in which case I could do a
> 
> #ifdef __CYGWIN__
> int main (int argc, char** argv)
> {
>    return realmain(argc, argv);
> }
> #endif

Or 

  #ifdef __CYGWIN__
  int main (int argc, char** argv)
  #else
  int realmain (int argc, char** argv)
  #endif

> and avoid the -e WinMain@16 link argument. (Except I think I arrange
> to only do -e WinMain@16 on mingw...hmm...)

Can you quickly check if that works?  If so, we have a bit less pressure
to fix libcmain.

> If you look closely at WinMain, it basically parses the result from
> GetCommandLine() into argc,argv, and then delegates.


Yes, I saw that while debugging.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 15:39             ` Corinna Vinschen
@ 2013-07-17 15:52               ` Charles Wilson
  2013-07-17 16:18                 ` Charles Wilson
  0 siblings, 1 reply; 17+ messages in thread
From: Charles Wilson @ 2013-07-17 15:52 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 10:33 AM, Corinna Vinschen wrote:
> Can you quickly check if that works?  If so, we have a bit less pressure
> to fix libcmain.

Seems to work for run2.exe.  Stay tuned for checkX.exe and run.exe.

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 15:52               ` Charles Wilson
@ 2013-07-17 16:18                 ` Charles Wilson
  2013-07-18  2:26                   ` Charles Wilson
  2013-07-25  2:38                   ` Charles Wilson
  0 siblings, 2 replies; 17+ messages in thread
From: Charles Wilson @ 2013-07-17 16:18 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 10:54 AM, Charles Wilson wrote:
> On 7/17/2013 10:33 AM, Corinna Vinschen wrote:
>> Can you quickly check if that works?  If so, we have a bit less pressure
>> to fix libcmain.
>
> Seems to work for run2.exe.  Stay tuned for checkX.exe and run.exe.

I've uploaded run2-0.4.2-2 as a test release for both 32bit and 64bit.

However, run is more complicated; most of the application code is 
actually in WinMain.  I've been meaning to refactor it more along the 
lines of run2, but never got around to it. Looks like I now have a 
reason...but it'll take a bit longer to do, and I won't really have time 
to address it until Saturday.

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 14:20     ` Corinna Vinschen
@ 2013-07-17 20:45       ` Christopher Faylor
  2013-07-17 20:46         ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Faylor @ 2013-07-17 20:45 UTC (permalink / raw)
  To: cygwin

On Wed, Jul 17, 2013 at 04:09:25PM +0200, Corinna Vinschen wrote:
>None.  Never works means, it's independent of the dir name of the CWD.
>It just never works.  In 1.7.21.

But, just wait until next Thursday...

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 20:45       ` Christopher Faylor
@ 2013-07-17 20:46         ` Corinna Vinschen
  0 siblings, 0 replies; 17+ messages in thread
From: Corinna Vinschen @ 2013-07-17 20:46 UTC (permalink / raw)
  To: cygwin

On Jul 17 14:45, Christopher Faylor wrote:
> On Wed, Jul 17, 2013 at 04:09:25PM +0200, Corinna Vinschen wrote:
> >None.  Never works means, it's independent of the dir name of the CWD.
> >It just never works.  In 1.7.21.
> 
> But, just wait until next Thursday...

I'm starting to be scared of Thursday.  I have to talk this through
with my therapist.  Or with my cat... if I knew where she is.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 16:18                 ` Charles Wilson
@ 2013-07-18  2:26                   ` Charles Wilson
  2013-07-25  2:38                   ` Charles Wilson
  1 sibling, 0 replies; 17+ messages in thread
From: Charles Wilson @ 2013-07-18  2:26 UTC (permalink / raw)
  To: cygwin

On 7/17/2013 11:52 AM, Charles Wilson wrote:
> On 7/17/2013 10:54 AM, Charles Wilson wrote:
>> On 7/17/2013 10:33 AM, Corinna Vinschen wrote:
>>> Can you quickly check if that works?  If so, we have a bit less pressure
>>> to fix libcmain.
>>
>> Seems to work for run2.exe.  Stay tuned for checkX.exe and run.exe.
>
> I've uploaded run2-0.4.2-2 as a test release for both 32bit and 64bit.
>
> However, run is more complicated; most of the application code is
> actually in WinMain.  I've been meaning to refactor it more along the
> lines of run2, but never got around to it. Looks like I now have a
> reason...but it'll take a bit longer to do, and I won't really have time
> to address it until Saturday.

Until then, users of run.exe affected by this problem can use run2.exe 
(today's new version) with almost the same effect:

1. create an XML file describing the program you want to launch. Here's 
an example:

<?xml version="1.0" encoding="us-ascii"?>
<Run2Config
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="run2.xsd">
   <SelfOptions />
   <Global>
     <Environment />
     <Target filename="/usr/bin/mintty.exe" startin="~">
       <Arg>-e /bin/bash -!-login</Arg>
     </Target>
   </Global>
</Run2Config>

2. Make sure all the arguments you want to pass to the target program 
are represented in (the|one of the) <Arg /> elements.  Be sure that all 
sequences of two '-' characters are replaced by -!- (see -!-login, above).

3. Create a shortcut with the following target:
C:\cygwin\bin\run2.exe /cygwin/path/to/your/xml/file

Enjoy.  (Try

C:\cygwin\bin\run2.exe --debug=3 --notty /cygwin/path/to/your/xml/file

if it doesn't work).

--
Chuck



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
  2013-07-17 16:18                 ` Charles Wilson
  2013-07-18  2:26                   ` Charles Wilson
@ 2013-07-25  2:38                   ` Charles Wilson
  1 sibling, 0 replies; 17+ messages in thread
From: Charles Wilson @ 2013-07-25  2:38 UTC (permalink / raw)
  To: The Cygwin Mailing List

On 7/17/2013 11:52 AM, Charles Wilson wrote:
> On 7/17/2013 10:54 AM, Charles Wilson wrote:
>> On 7/17/2013 10:33 AM, Corinna Vinschen wrote:
>>> Can you quickly check if that works?  If so, we have a bit less pressure
>>> to fix libcmain.
>>
>> Seems to work for run2.exe.  Stay tuned for checkX.exe and run.exe.
>
> I've uploaded run2-0.4.2-2 as a test release for both 32bit and 64bit.
>
> However, run is more complicated; most of the application code is
> actually in WinMain.  I've been meaning to refactor it more along the
> lines of run2, but never got around to it. Looks like I now have a
> reason...but it'll take a bit longer to do, and I won't really have time
> to address it until Saturday.

run-1.3.0 should operate normally, on cygwin-1.7.21 or cygwin-1.7.22 
(well, really, any version of cygwin-1.7.x) Note that this distribution 
of run-1.3.0 (a) was compiled on cygwin-1.7.21, so it does not take 
advantage of the compile-time fix provided by cygwin-1.7.22 [1], and (b) 
on __CYGWIN__ it uses the main() entry point rather than WinMain@16, and 
so does not access GetCommandLine() anyway (although it does use 
GetCommandLine(), when built for mingw[64,.org] targets)

[1] http://cygwin.com/ml/cygwin/2013-07/msg00438.html
> - Added cygwin GetCommandLine wrappers which will allow Cygwin programs to
>   (appear to) use the Windows command line functions.

--
Chuck



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-07-24 22:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-16 17:39 Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21) Andrey Repin
2013-07-16 18:02 ` Andrey Repin
2013-07-17 13:36 ` Corinna Vinschen
2013-07-17 14:02   ` Charles Wilson
2013-07-17 14:05     ` Corinna Vinschen
2013-07-17 14:09       ` Charles Wilson
2013-07-17 14:33         ` Corinna Vinschen
2013-07-17 14:54           ` Charles Wilson
2013-07-17 15:39             ` Corinna Vinschen
2013-07-17 15:52               ` Charles Wilson
2013-07-17 16:18                 ` Charles Wilson
2013-07-18  2:26                   ` Charles Wilson
2013-07-25  2:38                   ` Charles Wilson
2013-07-17 14:10   ` Andrey Repin
2013-07-17 14:20     ` Corinna Vinschen
2013-07-17 20:45       ` Christopher Faylor
2013-07-17 20:46         ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).