Cred ca nu m-am facut inteles.<br>Creez cate un pipe pt fiecare (si A si B)<br>A - pt stdout si B pentru stdin.<br>Stiu ca puteam sa fac asta direct dar am vrut sa fac asa.<br>Fac asa:<br>[code]<br> SECURITY_ATTRIBUTES saAttr; <br>
// Set the bInheritHandle flag so pipe handles are inherited. <br> saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); <br> saAttr.bInheritHandle = TRUE; <br> saAttr.lpSecurityDescriptor = NULL; <br>
<br> //adaugam pipe info in procesul anterior<br> MyProcess lastProc = pipeProcesses[pipeProcesses.size() - 1];<br> // Create a pipe for the child process's STDOUT. <br> if ( ! CreatePipe(&lastProc.sPipes.hStdOUT_Rd, &lastProc.sPipes.hStdOUT_Wr, &saAttr, 0) ) <br>
cerr<<"Stdout Pipe CreatePipe";<br> // Ensure the read handle to the pipe for STDOUT is not inherited.<br> if ( ! SetHandleInformation(lastProc.sPipes.hStdOUT_Rd, HANDLE_FLAG_INHERIT, 0) )<br>
cerr<<"Stdout Pipe SetHandleInformation"; <br> lastProc.pipeFlag |= PIPE_OUT;<br> pipeProcesses[pipeProcesses.size() - 1] = lastProc;<br> if ( ! CreatePipe(&crtProcess.sPipes.hStdIN_Rd, &crtProcess.sPipes.hStdIN_Wr, &saAttr, 0) ) <br>
cerr<<"Stdin CreatePipe";<br> // Ensure the read handle to the pipe for STDOUT is not inherited.<br> if ( ! SetHandleInformation(crtProcess.sPipes.hStdIN_Wr, HANDLE_FLAG_INHERIT, 0) )<br>
cerr<<"Stdin SetHandleInformation"; <br> crtProcess.pipeFlag = PIPE_IN;<br>[/code]<br><br>Ideea e ca _functioneaza_, dar numai in debug.<br>Lasand tema la o parte, intrebarea mea este daca si (daca da) cum pot sa astept terminarea scrierii in pipe.<br>
<br>David.<br><br><div class="gmail_quote">2009/4/5 Razvan Deaconescu <span dir="ltr"><<a href="mailto:razvan.deaconescu@cs.pub.ro">razvan.deaconescu@cs.pub.ro</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Sun, 2009-04-05 at 22:54 +0300, David Cristian wrote:<br>
> Fiecare proces din pipe are o structura :<br>
> typedef struct<br>
> {<br>
> HANDLE hStdOUT_Rd;<br>
> HANDLE hStdOUT_Wr;<br>
> HANDLE hStdIN_Rd;<br>
> HANDLE hStdIN_Wr;<br>
> }Pipe;<br>
><br>
> Daca am A | B, A are stdout : hStdOUT_Wr si B are stdin: hStdIN_Rd.<br>
> Am setat sa fie inheritable doar hStdOUT_Wr pt A si hStdIN_Rd pentru<br>
> B.<br>
><br>
> Procesul tata citeste din hStdOUT_Rd al lui A si scie in hStdIN_Wr.<br>
><br>
> Poate e o abordare gresita, dar as vrea sa vad cum s-ar putea<br>
> solutiona<br>
> (de ce merge daca pun breakpoint si daca rulez normal nu).<br>
> Banuiesc ca nu se termina de scris in pipe inainte de a se incerca<br>
> citirea.<br>
<br>
</div>Apelul CreatePipe[1] este folosit pentru crearea de pipe-uri. Tu nu-l<br>
folosesti?<br>
<br>
Razvan<br>
<br>
[1] <a href="http://msdn.microsoft.com/en-us/library/aa365152%28VS.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/aa365152(VS.85).aspx</a><br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
so mailing list<br>
<a href="mailto:so@cursuri.cs.pub.ro">so@cursuri.cs.pub.ro</a><br>
<a href="http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so" target="_blank">http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so</a><br>
</div></div></blockquote></div><br>