Changeset - cc2161d16a5b
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 17 years ago 2009-02-21 01:18:44
ohnobinki@ohnopublishing.net
close the correct end of pipes at the right time
1 file changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/common/remoteio.c
Show inline comments
 
@@ -24,6 +24,7 @@
 
#include <sys/wait.h>
 
#include <signal.h>
 
#include <malloc.h>
 
#include <stdio.h>
 

	
 
int remoteio_open(const char *spec, struct remoteio **rem)
 
{
 
@@ -59,6 +60,10 @@ int remoteio_open(const char *spec, stru
 
    }
 
  if(child)
 
    {
 
      /* close sides of pipe we won't use */
 
      close(pipe_write[0]);
 
      close(pipe_read[1]);
 
      
 
      /* setup remoteio struct */
 
      (*rem) = malloc(sizeof(struct remoteio));
 
      if(!(*rem))
 
@@ -82,6 +87,11 @@ int remoteio_open(const char *spec, stru
 
  /* child */
 
  else
 
    {
 
      /* close unused pipes */
 
      close(pipe_write[1]);
 
      close(pipe_read[0]);
 

	
 
      /* reset stdin, stdout, and stderr to the appropriate streams. OK, not stderr :-) */
 
      
 

	
 
      return 1; /* this line should never be reached because we exec*/
0 comments (0 inline, 0 general)