Changeset - 06d8d6cb898f
[Not reviewed]
Merge default
0 1 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-09-03 00:11:54
e@ethanzonca.com
Merge
1 file changed with 3 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/common/execio.c
Show inline comments
 
@@ -130,15 +130,12 @@ int execio_open(struct execio **rem, con
 
	{
 
	  if(!close(counter))
 
	    counter2 ++; /* record how many descriptors we still had open :-) */
 
	  counter --;
 
	}
 
      
 
      /* stderr is the only stream we haven't confiscated atm - just for fun - I will confiscate it later, though, to support parsing error messages */
 
      fprintf(stderr, "closed %d/%d fds before execing \"%s\"\n", counter2, maxfds, progname);
 

	
 
      /*
 
	now exec: execvp uses interpreter to find the file to exec
 
       */
 
      execvp(progname, argv);
 

	
 
      fprintf(stderr, "uh-oh, ``%s'' didn't start for execio\n", progname);
 
@@ -212,15 +209,15 @@ int execio_write(struct execio *eio, con
 
      switch(errno)
 
	{
 
	case EPIPE:
 
	  /* 
 
	     the program closed the pipe (died)
 
	  */
 
	fprintf(stderr, "execio_write: the child program closed its stdin pipe\n");
 
	eio->state = EXECIO_STATE_EOF;
 
	break;
 
	  fprintf(stderr, "execio_write: the child program closed its stdin pipe\n");
 
	  eio->state = EXECIO_STATE_EOF;
 
	  break;
 
	
 
	default:
 
	  fprintf(stderr, "execio_write: unhandled error writing to an fd: \n");
 
	  perror("write");
 
	  eio->state = EXECIO_STATE_ERROR;
 
	  break;
 
@@ -250,13 +247,12 @@ int execio_close(struct execio *eio)
 
  /* maybe we should just kill rather than term the child */
 
  kill(eio->child, SIGTERM);
 
  /* 
 
     the waitpid(2) seems to indicate that only when the child is terminated will this wait return. 
 
     This are of code will probably need improving - the ability to seng SIGKILL after a timeout? So we'll output a debug line before running waitpid
 
  */
 
  fprintf(stderr, "execio_close: running waitpid\n");
 
  waitpid(eio->child, &childstatus, 0);
 

	
 
  free(eio);
 
  
 
  return 0;
 
}
0 comments (0 inline, 0 general)