dilettante
MIS
I tried searching here and didn't find a good answer... heck, I've tried searching lots of places. I wish I had Appleman's API book to look at too but I don't have a copy.
I have a process that initiates a child process using [tt]CreateProcess()[/tt], redirecting the standard I/O streams in a pretty conventional manner via anonymous pipes. The problem is that I have some old code I need to run as the "child" and it needs to receive an EOF status on its StdIn to signal "end of input."
Of course running the program manually via CMD.EXE it works fine. Pressing CTRL-Z causes the application to see EOF and it sends a response and finishes.
From my VB program acting as a parent (in place of the CMD.EXE shell) this doesn't seem to be working though.
How do you "send" an EOF on an anonymous (or named, for that matter) pipe?
More background:
The documentation seems a little vague, and I believe I have tried everything obvious. Yes, I have made made sure that the child process does not inherit the handle to the write end of the StdIn pipe (nor the read end of my StdOut/StdErr pipe) using [tt]SetHandleInformation()[/tt] too.
Thing #1:
In the parent process, signal EOF by closing the write end of the StdIn pipe to the child. Make sure that the child process does not inherit the handle to the write end of the StdIn pipe.
Thing #2:
In the parent process, signal EOF by doing a "null write" (zero bytes length) through the write end of the StdIn pipe to the child.
Thing #3:
Null write followed by close of the write end of the child's StdIn pipe.
None of those "things" seems to work.
Even stranger, one small program I found and that I have the source code to only wants to read "lines" (waits for input up to a CR/LF). It is so agressive about wanting "lines" that it doesn't even detect EOF on it's StdIn input properly unless the EOF is followed by an input CR/LF!
This seems odd, but it works fine from CMD.EXE: run this program, type in:
[tt]
C:\>littletest.exe
text<enter>
type more text<enter>
^Z<enter>
I saw 2 lines of input.
C:\>
[/tt]
... and it ends just fine. BUT not until after the enter key is pressed following the CTRL-Z.
So... this seems to indicate that EOF on a StdIn stream redirected via an anonymous pipe is not a closure at the other end of the pipe. Unless... does CMD.EXE close the redirected StdIn pipe and then immediately re-open it???
Weirdly enough I have the CTRL-C and CTRL-Break interrupts working fine. When the parent process requests termination in this manner the child finishes up and the read end of the child's StdOut pipe gets a "broken pipe" error as expected.
I have a process that initiates a child process using [tt]CreateProcess()[/tt], redirecting the standard I/O streams in a pretty conventional manner via anonymous pipes. The problem is that I have some old code I need to run as the "child" and it needs to receive an EOF status on its StdIn to signal "end of input."
Of course running the program manually via CMD.EXE it works fine. Pressing CTRL-Z causes the application to see EOF and it sends a response and finishes.
From my VB program acting as a parent (in place of the CMD.EXE shell) this doesn't seem to be working though.
How do you "send" an EOF on an anonymous (or named, for that matter) pipe?
More background:
The documentation seems a little vague, and I believe I have tried everything obvious. Yes, I have made made sure that the child process does not inherit the handle to the write end of the StdIn pipe (nor the read end of my StdOut/StdErr pipe) using [tt]SetHandleInformation()[/tt] too.
Thing #1:
In the parent process, signal EOF by closing the write end of the StdIn pipe to the child. Make sure that the child process does not inherit the handle to the write end of the StdIn pipe.
Thing #2:
In the parent process, signal EOF by doing a "null write" (zero bytes length) through the write end of the StdIn pipe to the child.
Thing #3:
Null write followed by close of the write end of the child's StdIn pipe.
None of those "things" seems to work.
Even stranger, one small program I found and that I have the source code to only wants to read "lines" (waits for input up to a CR/LF). It is so agressive about wanting "lines" that it doesn't even detect EOF on it's StdIn input properly unless the EOF is followed by an input CR/LF!
This seems odd, but it works fine from CMD.EXE: run this program, type in:
[tt]
C:\>littletest.exe
text<enter>
type more text<enter>
^Z<enter>
I saw 2 lines of input.
C:\>
[/tt]
... and it ends just fine. BUT not until after the enter key is pressed following the CTRL-Z.
So... this seems to indicate that EOF on a StdIn stream redirected via an anonymous pipe is not a closure at the other end of the pipe. Unless... does CMD.EXE close the redirected StdIn pipe and then immediately re-open it???
Weirdly enough I have the CTRL-C and CTRL-Break interrupts working fine. When the parent process requests termination in this manner the child finishes up and the read end of the child's StdOut pipe gets a "broken pipe" error as expected.