title: Should named pipes opened with mkfifo be closed and how?
body: <p>I am using a named pipe to capture the output of an external program (wgrib2) within another program (MATLAB). The MATLAB code is below, and <code>system()</code> accesses the command line to make the pipe:</p>
  <pre class="lang-matlab prettyprint-override"><code>system('mkfifo myfifo');     % Make a named pipe myfifo
  % Call the external program wgrib2 and dump its output to the named pipe myfifo
  system('wgrib2.exe multi_1.glo_30m.hs.201212.grb2 -ij 1 165 -ij 1 166 &gt; myfifo &amp;');
  fid = fopen('myfifo', 'r');  % Open the named pipe
  a = fscanf(fid, '%c');       % Read the output as character
  fclose(fid);                 % Close the &quot;file&quot; (myfifo still exists afterward)
  </code></pre>
  <p>Here are my questions:</p>
  <ol>
  <li>Do I have to close the named pipe <code>myfifo</code> after I use it? It seems to persist after the code is run.</li>
  <li>If <code>myfifo</code> needs to be closed, what is the command to close it?</li>
  <li>I will be running the code sample above many times (&gt;1000), so is it OK if I reuse the named pipe and do not close it until the end?</li>
  </ol>