Spawning a console in Windows (similar to forkpty on linux)

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 9 05:26:57 PDT 2015


On Saturday, 9 May 2015 at 12:25:32 UTC, wobbles wrote:
> On Saturday, 9 May 2015 at 12:16:52 UTC, Rikki Cattermole wrote:
>> On 10/05/2015 12:13 a.m., wobbles wrote:
>>> This isn't specifically a D question, but seeing as it's for 
>>> a D library
>>> I figure it can go here :)
>>>
>>> On Windows, I want to be able to spawn a console and then 
>>> interact with
>>> its stdin/out asynchronously, similar to how forkpty [1] 
>>> works on linux.
>>>
>>> I'm improving my dexpect library [2] to work with windows 
>>> machines and
>>> this bit has me stumped. There doesnt seem to be much info 
>>> about it that
>>> I can find (though my google-fu mightn't be good enough!!)
>>>
>>> I'm sure theres someone here who knows something?
>>>
>>> Thanks!
>>>
>>> [1] http://linux.die.net/man/3/forkpty
>>> [2] https://github.com/grogancolin/dexpect
>>
>> Did you try creating a new process which is cmd?
>> Because std.process should be able to handle the IO part.
>
> I have, but they all block i/o and so I cant continually read 
> from its output :/

What I mean is, if the cmd.exe hasnt flushed it's output, my 
cmdPid.stdout.readln (or whatever) will block until it does. I 
dont really want this.

I guess I need to make another thread to do this so I wont block 
the main thread?


More information about the Digitalmars-d-learn mailing list