Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need two pipes, one for the process to send output to you (<code>stdout</code>), and one for you to send input to the process (<code>stdin</code>). </p> <p>From your code, it looks like you are putting both ends of the <em>same</em> pipe into the <code>TStartupInfo</code> record. So you are effectively making the process talk to itself. :-)</p> <p>So, you need to call <code>CreatePipe()</code> twice, to create two pipes, one for <code>stdin</code>, one for <code>stdout</code> (and <code>stderr</code>).</p> <p>Then, put the reading handle of <code>stdin</code> in <code>suiStartup.hStdInput</code> and the writing handle of <code>stdout</code> in <code>suiStartup.hStdOutput</code></p> <p>To send data to the process, write to the write handle of the <code>stdin</code> pipe. To read the output of the process, read the read handle of the <code>stdout</code> pipe.</p> <p><strong>Edit: (again)</strong></p> <p>As for all the duplicating handles and inheritable and non-inheritable stuff described on <a href="http://support.microsoft.com/kb/190351" rel="noreferrer">this page</a> (specifically in the code example), you <em>need</em> to make sure the handles you send to the process are inheritable (as you have done). </p> <p>You <em>should</em> also make sure the handles of the pipes that the parent process use are <em>not inheritable</em>. But you don't <em>have</em> to do this... I've gotten away with not doing it before.</p> <p>You can do this by either calling <code>DuplicateHandle()</code> on the handles, specifying they are not inheritable and closing the old handles, or calling <code>SetHandleInformation()</code> with 0 specified for the flags (as discussed <a href="http://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx" rel="noreferrer">here</a>). </p> <p>It's been a while since I have done this myself, but I'm pretty sure this is so that the reference count for the handles is associated with the calling process, rather than the child process. This prevents a handle being closed whilst you're still using it (the calling process might close 'stdin' for example). Make sure you close the handles though, otherwise you will end up leaking handles.</p> <p>HTH.</p> <p>N@</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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