Note that there are some explanatory texts on larger screens.

plurals
  1. PObroken pipe in win32 (WinAPI)
    primarykey
    data
    text
    <p>I have followed the example <a href="http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx" rel="nofollow">here</a> for reading from a pipe, but ReadFile fails and GetLastError() shows me that the pipe is broken.<br> I have created and used (successfully) a pipe earlier in the program, but I closed all the handles and used entirely new variables for the new pipe just to be sure.<br> Any ideas why this doesn't work?</p> <pre><code>HANDLE g_hChildStd_OUT_Rd2 = NULL; HANDLE g_hChildStd_OUT_Wr2 = NULL; SECURITY_ATTRIBUTES saAttr2; STARTUPINFO si2; PROCESS_INFORMATION pi2; ZeroMemory( &amp;si2, sizeof(si2) ); si2.cb = sizeof(si2); ZeroMemory( &amp;pi2, sizeof(pi2) ); //create pipe saAttr2.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr2.bInheritHandle = TRUE; saAttr2.lpSecurityDescriptor = NULL; CreatePipe(&amp;g_hChildStd_OUT_Rd2, &amp;g_hChildStd_OUT_Wr2, &amp;saAttr2, 0); //create child process bSuccess = FALSE; memset(szCmdLine, 0, MAX_PATH); sprintf(szCmdLine, "ffmpeg.exe -i output.mp3"); ZeroMemory( &amp;pi2, sizeof(PROCESS_INFORMATION) ); ZeroMemory( &amp;si2, sizeof(STARTUPINFO) ); si2.cb = sizeof(STARTUPINFO); si2.hStdOutput = g_hChildStd_OUT_Wr2; si2.dwFlags |= STARTF_USESTDHANDLES; CreateProcess(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &amp;si2, &amp;pi2); //read from pipe CloseHandle(g_hChildStd_OUT_Wr2); memset(chBuf, 0, BUFSIZE); for (;;) { bSuccess = ReadFile( g_hChildStd_OUT_Rd2, chBuf, BUFSIZE, &amp;dwRead, NULL); [bSuccess is 0 and GetLastError() returns error 109] ........ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload