Detect that a child is waiting for input

wobbles via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 22 14:30:06 PST 2016


On Monday, 21 November 2016 at 07:29:55 UTC, unDEFER wrote:
> On Sunday, 20 November 2016 at 21:03:57 UTC, John Colvin wrote:
>> If blocking is an error, you could close stdin and assuming 
>> the process checks the error codes correctly....
>
> No, I mean blocking is not error.
> One method to find it, run gdb or strace and see where the 
> process stopped, or which syscall was last. But I believe that 
> must be other way.

Easier said than done as there's no signal the child sends to say 
"OK, I'm waiting now".

You can use expect to do this, if you know what the output of the 
child will be just before it's waiting for IO.

This is the D lib I've written to do this:
https://github.com/grogancolin/dexpect

It's not wonderful or anything, but it works :)


More information about the Digitalmars-d mailing list