Changeset - 510b082d50ae
[Not reviewed]
default
0 3 0
Nathan Brink (binki) - 17 years ago 2009-02-23 21:38:50
ohnobinki@ohnopublishing.net
improvements to comments, calling execio_open, and verbosity of execio.c
3 files changed with 14 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -19,7 +19,9 @@
 

	
 
#include <stdio.h> /* sprintf, printf */
 
#include <stdlib.h> /* malloc, free */
 

	
 
#include "options.h"
 
#include "execio.h"
 

	
 
int main(int argc, char *argv[])
 
{
 
@@ -28,8 +30,10 @@ int main(int argc, char *argv[])
 
    {
 
      "ssh",
 
      "protofusion.org",
 
      "echo",
 
      "hello from protofusion.org"
 
      "sh",
 
      "-c",
 
      "\"echo hello from ${HOSTNAME} 1>&2\"",
 
      (char *)NULL
 
    };
 

	
 
  fprintf(stderr, "testing execio (It shouldn't work) :-)\n");
src/common/execio.c
Show inline comments
 
@@ -40,6 +40,7 @@ int execio_open(struct execio **rem, con
 
  
 
  int counter;
 
  int counter2;
 
  int maxfds;
 

	
 
  /* create two pipes to facilitate communication with child */
 
  if(pipe(pipe_write))
 
@@ -111,6 +112,7 @@ int execio_open(struct execio **rem, con
 
      if(counter < pipe_read[1])
 
	counter = pipe_read[1];
 
      counter2 = 0;
 
      maxfds = counter;
 
      while(counter > 2)
 
	{
 
	  if(!close(counter))
 
@@ -119,7 +121,7 @@ int execio_open(struct execio **rem, con
 
	}
 
      
 
      /* 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 fds before execing \"%s\"\n", counter2, progname);
 
      fprintf(stderr, "closed %d/%d fds before execing \"%s\"\n", counter2, maxfds, progname);
 

	
 
      /*
 
	now exec: execvp uses interpreter to find the file to exec
src/common/execio.h
Show inline comments
 
@@ -41,7 +41,11 @@ struct execio
 
  pid_t child;
 
};
 

	
 
/* nonzsero return on error */
 
/*
 
  runs progname with the arguments in argv. argv must be null terminated!!!!!!!!!
 

	
 
  returns nonzsero return on error 
 
*/
 
int execio_open(struct execio **rem, const char *progname, char *const argv[]);
 

	
 
/* 
0 comments (0 inline, 0 general)