popen/pclose: unexpected behavior

John O\'Leary joleary@ichips.intel.com
Mon Oct 3 18:52:00 GMT 2005


Hello,

The following program hangs when its pipes are closed in the same order in 
which they were opened, and terminates when its pipes are closed in the 
reverse order. 

I've never seen this on other platforms - it a bug? Or is there a subtlety I'm 
unaware of?

Thanks
--John

----------------------------------------

#include <stdio.h>

int main (void) 
{
  FILE *pipe1;
  FILE *pipe2;

  pipe1 = popen ("cat", "w");
  pipe2 = popen ("cat", "w");

  /* hangs unless pipes are pclosed in order pipe2,pipe1 */
  pclose (pipe1);
  pclose (pipe2);

  return 0;
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list