diff options
Diffstat (limited to 'rpt.c')
| -rw-r--r-- | rpt.c | 21 | 
1 files changed, 14 insertions, 7 deletions
| @@ -15,6 +15,13 @@  /* Size of the buffer used to clone stdin. */  #define BUFSIZE 8000 +/* Exit status */ +#define EXIT_SUCCESS 0 +#define EXIT_INVALID_ARG 1 +#define EXIT_INVALID_COUNT 2 +#define EXIT_NO_COMMAND 3 +#define EXIT_OTHER 4 +  /* Clone of stdin.  Used to perform lseek(2) calls between each child     process. */  FILE *stdin_clone = NULL; @@ -80,7 +87,7 @@ exec_child(char **argv)  		if (status < 0)  		{  			perror("lseek"); -			exit(4); +			exit(EXIT_OTHER);  		}  	} @@ -89,7 +96,7 @@ exec_child(char **argv)  	if (status < 0)  	{  		perror("dup2"); -		exit(4); +		exit(EXIT_OTHER);  	}  	status = execvp(argv[0], argv); @@ -97,10 +104,10 @@ exec_child(char **argv)  	if (status < 0)  	{  		perror("execvp"); -		exit(4); +		exit(EXIT_OTHER);  	} -	exit(4); +	exit(EXIT_OTHER);  }  void @@ -121,7 +128,7 @@ invoke_cmd(char **argv, void (*handle_error_f)(int status))  	if (pid < 0)  	{  		perror("fork"); -		exit(4); +		exit(EXIT_OTHER);  	}  	if (pid == 0) @@ -150,7 +157,7 @@ copy_stdin()  	if (!stdin_clone)  	{  		perror("tmpfile"); -		exit(1); +		exit(EXIT_OTHER);  	}  	clone_fd = fileno(stdin_clone); @@ -165,7 +172,7 @@ copy_stdin()  	{  		fclose(stdin_clone);  		perror("read/write"); -		exit(1); +		exit(EXIT_OTHER);  	}  } | 
