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: [RFA] patch for run.exe -- ATTN: ago

Alexander Gottwald wrote:

Actually GetStdHandle seems to work with pipes.

run cat foo | less cat foo | run cat | less

but this does exit immediatly
run cat | less


So the invisible console should provide stdin, stdout and stderr where
stdout and stderr will discard any written data and stdin should never
return data on read.

Nor should the "stdin" pipe ever be "ready" if select() is called on its read end. I'm sure that ought to be true -- as long as run doesn't stuff any data into the write end of it.

creating a pipe for stdin could be useful. maybe creating one for stdout
and stderr which is always read too.

start.hStdInput = GetStdHandle(STD_INPUT_HANDLE); start.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); start.hStdError = GetStdHandle(STD_ERROR_HANDLE);


if (start.hStdInput == INVALID_HANDLE_VALUE)
CreatePipe(&hpStdInput[0], &hpStdInput[1], NULL, 0);
start.hStdInput = hpStdInput[0];
if (start.hStdOutput == INVALID_HANDLE_VALUE || start.hStdError == INVALID_HANDLE_VALUE)
CreatePipe(&hpStdOutput[0], &hpStdOutput[1], NULL, 0);
if (start.hStdOutput == INVALID_HANDLE_VALUE)
start.hStdOutput = hpStdOutput[1];
if (start.hStdError == INVALID_HANDLE_VALUE)
start.hStdError = hpStdOutput[1]; }
sec_attrs.nLength = sizeof (sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE;

   if (CreateProcess (NULL, cmdline, &sec_attrs, NULL, TRUE, 0,
                      NULL, NULL, &start, &child))
      if (wait_for_child)
         if (hpStdOutput[0] != INVALID_HANDLE_VALUE)
           HANDLE handles[2] = { child.hProcess, hpStdOutput[0] };
           while (WaitForMultipleObjects (2, handles, FALSE, INFINITE) == WAIT_OBJECT_0 + 1)
             char buffer[1024];
	     DWORD dwRead;
             ReadFile (hpStdOutput[0], buffer, 1024, &dwRead, NULL);
         } else {
           WaitForSingleObject (child.hProcess, INFINITE);
         GetExitCodeProcess (child.hProcess, &retval);
      CloseHandle (child.hThread);
      CloseHandle (child.hProcess);

Unfortunately this doesn't solve my problem (after disabling the setup_invisible_console() call). There are two reasons:

(1) as it happens, GetStdHandle does *not*, in fact, return INVALID_HANDLE_VALUE. I thought it would given my reading of the docs. I thought it DID when I tested it. But I was wrong. It's returning some non-zero, non-INVALID_HANDLE_VALUE-value. I have no idea why.

(2) Even if I force your pipe code to activate (by explicitly assigning INVALID_HANDLE_VALUE to start.hStdInput and friends at the top of the code block above), rxvt-unicode-X still goes haywire.

Sigh. Hopefully I'll have time to look into this more over the weekend. Maybe something like

Anyway, if the allocated hidden console does not interfere with the
pipes i'm going to add it.

??? the pipe code? or the setup_invisible_console code? or both?

Is it possible to create a console on win9x and hide it again. This will
flash, but at least it does work.

Well, yeah...but then you might as well not even use run.exe for launching rxvt or rxvt-unicode. They can hide their console all by them selves, if you don't mind the brief flash.


Unsubscribe info:
Problem reports:

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