Thanks, Doug. I use cygstart.exe to start windows programs (such as winword or notepad) from
a mintty/bash console in a way that allows the mintty console to be closed while the windows application is still active. I thought run.exe was meant to be used from shortcuts to run cygwin programs without flashing a console window on the desktop. I don't think it's needed to start programs from a mintty console. >________________________________ > From: Doug Henderson <djndn...@gmail.com> >To: "cygwin@cygwin.com" <cygwin@cygwin.com> >Sent: Thursday, October 23, 2014 2:34 PM >Subject: Re: run.exe flashes non-hidden console window in cygwin64 on >Win7Pro-64 > > >On 23 October 2014 06:24, John Wiersba > wrote: >> Maybe I'm confused. Isn't the purpose of run.exe to start a >> cygwin program without creating a (visible) console window? >> I can just start a cygwin program directly without the indirection of >> run.exe if I don't care about the random flashing console window. >> >> From the run.exe manpage: >> run will do this for you. It works as intermediate and starts a program >> but makes the console window hidden. > >AFAIK, all programs that run in Windows need a window handle in order >to receive events, and to pass to a lot of windows functions. If your >program create a windows before it tries to do anything that requires >a window, that window gets used. When your program does not create its >own windows, the start up code tries to attach you to an existing >console window, and if there is not one, it creates it. > >A Windows GUI program starts at winmain(). This entry point does not >have the same requirements as the C standard main() entry point. >Mainly, you do not have the stdin, stdout, and stderr attached to >anything, and you do not have a window. Creating a console or GUI >window is entirely up to your code. > >Normally, any non-GUI program will attach to the console window where >it starts. A "dos" type program will attach to the window running the >cmd.exe that started it, and a cygwin program will get attached to the >mintty console window to which your shell is attached, > >For both types of non-GUI programs, the msvcrt.dll or cygwin1.dll >runtime code will setup stdin, stdout and stderr before entering >main(). The runtime startup code will create a console window for you >if you did not inherit one from your parent process, and the code will >attach those file pointers to the console window > >In any system: Windows, cygwin, linux, or whatever, to create a >windowless process, you close those initial file pointers or file >handles and fork a new process. In the original process, you close >your window if necessary, you call exit(), and the runtime will close >your window if necessary. In the new process, you do what ever you >want. > >When you have a cmd.exe window, you use "start" to fire off a new >program and control what happens to its window with command line >options. >When you have a shell in a cygwin console, you use "run.exe" at the >shell prompt. >When you use a shortcut, you have not initial window, so the >msvcrt.dll runtime creates one for you, and uses the properties of the >shortcut to control how that window is created. > >At the shell prompt, try the following commands: > >$ /cygdrive/c/windows/system32/notepad.exe > >$ /cygdrive/c/windows/system32/notepad.exe & > >$ run /cygdrive/c/windows/system32/notepad.exe > >$ run /cygdrive/c/windows/system32/notepad.exe & > >use ps to check how the notepad process is connected to cygwin. Try >exiting the shell after the second command to see why you want to use >run. > >Anyway, that's how I think things work. But I may be wrong. It may >give you some ideas on where to look for more correct and/or detailed >answers. -- 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