Overlapped ReadFileEx on Child Process' Redirected STDOUT Never Fires

前端 未结 2 1402
臣服心动
臣服心动 2021-01-13 22:15

I have a long-running console-based application Sender that sends simple text to STDOUT using non-buffered output such as cout << \"Message\" << flush(). I want

2条回答
  •  执笔经年
    2021-01-13 22:25

    I think you have a typo:

    CreatePipe(&handles[h_Child_StdOut_Read], &handles[h_Child_StdOut_Write], &sa, 0);
    SetHandleInformation(handles[h_Child_StdOut_Read], HANDLE_FLAG_INHERIT, 0);
    CreatePipe(&handles[h_Child_StdIn_Read], &handles[h_Child_StdIn_Write], &sa, 0);
    SetHandleInformation(handles[h_Child_StdIn_Read], HANDLE_FLAG_INHERIT, 0);
    

    change the last one to

    SetHandleInformation(handles[h_Child_StdIn_Write], HANDLE_FLAG_INHERIT, 0);

    that's also what they do at the MSDN example.

提交回复
热议问题