views:

17

answers:

0

Greetings everyone.

I'm capturing an output from a process created using CreateProcess() through the redirected named pipes for stdout and stderr. I also send an input to the redirected stdin.

Everything goes fine except one big annoying thing. Sometimes it's unknown what data needs to be written in stdin and I present a simple dialog to the user with ability to fill required data and send it back with EOL or EOD.

The big problem, which I'm unable to solve, is how do I determine if created process actually awaits for the input and not output?

There's a GetThreadIOPendingFlag() function in WinAPI but it checks for both input and output which means the prompt can be issued when there's no input pending at all and user will be confused.

So is there any way / technique I can use with my stdin pipe or thread or process to determine for pending input just like Windows command prompt (for example) does? I'm not quite a master with pipes but I thought if it works as expected in prompt, there might be some obvious solution. Thanks for any help.

P.s. I'm writing in Delphi myself but since it's not a language-specific question (rather a technology one) I didn't tag it as Delphi one. Your code in any language will be very much appreciated.