This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: run: requires CYGWIN=tty?


On Nov 26 10:35, Corinna Vinschen wrote:
> However, Chuck, can you please try the below patch to run.c instead?
> It makes the stdout and stderr handles already distinct in run:
> 
> Index: src/run.c
> ===================================================================
> RCS file: /cvs/cygwin-apps/run/src/run.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 run.c
> --- src/run.c	18 Aug 2009 15:51:05 -0000	1.9
> +++ src/run.c	26 Nov 2009 09:33:11 -0000
> @@ -418,7 +418,10 @@ BOOL configure_startupinfo(STARTUPINFO* 
>        psi->hStdOutput  = CreateFile( "CONOUT$", GENERIC_WRITE | GENERIC_READ,
>                           FILE_SHARE_WRITE, &sa,
>                           OPEN_EXISTING, 0, 0 );
> -      psi->hStdError   = psi->hStdOutput;
> +      if (!DuplicateHandle (GetCurrentProcess (), psi->hStdOutput,
> +			    GetCurrentProcess (), &psi->hStdError,
> +			    0, TRUE, DUPLICATE_SAME_ACCESS))
> +	psi->hStdError = psi->hStdOutput;
>  
>        Trace(("Have a console, and not requesting pipes: connecting child stdio to console"));
>        return TRUE;

Erm... btw., I would change the sharing flags as well.  I don't know
how much influence they have on a console handle, but they certainly
*look* wrong.  You can also just simply call CreateFile for the
stderr handle as well, same as for the stdout handle:

Index: src/run.c
===================================================================
RCS file: /cvs/cygwin-apps/run/src/run.c,v
retrieving revision 1.9
diff -u -p -r1.9 run.c
--- src/run.c	18 Aug 2009 15:51:05 -0000	1.9
+++ src/run.c	26 Nov 2009 11:04:20 -0000
@@ -413,12 +413,14 @@ BOOL configure_startupinfo(STARTUPINFO* 
 
       *bUsingPipes = FALSE;
       psi->hStdInput   = CreateFile( "CONIN$", GENERIC_WRITE | GENERIC_READ,
-                         FILE_SHARE_READ, &sa,
+                         FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
                          OPEN_EXISTING, 0, 0 );
       psi->hStdOutput  = CreateFile( "CONOUT$", GENERIC_WRITE | GENERIC_READ,
-                         FILE_SHARE_WRITE, &sa,
+                         FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
+                         OPEN_EXISTING, 0, 0 );
+      psi->hStdError   = CreateFile( "CONOUT$", GENERIC_WRITE | GENERIC_READ,
+                         FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
                          OPEN_EXISTING, 0, 0 );
-      psi->hStdError   = psi->hStdOutput;
 
       Trace(("Have a console, and not requesting pipes: connecting child stdio to console"));
       return TRUE;

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]