Code Cleanup

- Improved white space for readability and style compliance.
This commit is contained in:
Paul Beckingham
2014-11-28 12:15:00 -05:00
parent 7ca40db738
commit 9a95696872

View File

@@ -277,15 +277,14 @@ int execute (
int select_retval, read_retval, write_retval; int select_retval, read_retval, write_retval;
char buf[16384]; char buf[16384];
int written; int written;
const char * input_cstr = input.c_str (); const char* input_cstr = input.c_str ();
if (signal (SIGPIPE, SIG_IGN) == SIG_ERR) // Handled locally with EPIPE. if (signal (SIGPIPE, SIG_IGN) == SIG_ERR) // Handled locally with EPIPE.
{
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
}
if (pipe (pin) == -1) if (pipe (pin) == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
if (pipe (pout) == -1) if (pipe (pout) == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
@@ -297,6 +296,7 @@ int execute (
// This is only reached in the child // This is only reached in the child
if (dup2 (pin[0], STDIN_FILENO) == -1) if (dup2 (pin[0], STDIN_FILENO) == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
if (dup2 (pout[1], STDOUT_FILENO) == -1) if (dup2 (pout[1], STDOUT_FILENO) == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
@@ -327,6 +327,7 @@ int execute (
{ {
FD_SET (pin[1], &wfds); FD_SET (pin[1], &wfds);
} }
tv.tv_sec = 5; tv.tv_sec = 5;
tv.tv_usec = 0; tv.tv_usec = 0;
@@ -359,16 +360,19 @@ int execute (
read_retval = read (pout[0], &buf, sizeof(buf)-1); read_retval = read (pout[0], &buf, sizeof(buf)-1);
if (read_retval == -1) if (read_retval == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
buf[read_retval] = '\0'; buf[read_retval] = '\0';
output += buf; output += buf;
} }
} }
close (pin[1]); // Close the write end of the input pipe. close (pin[1]); // Close the write end of the input pipe.
close (pout[0]); // Close the read end of the output pipe. close (pout[0]); // Close the read end of the output pipe.
int status = -1; int status = -1;
if (wait (&status) == -1) if (wait (&status) == -1)
throw std::string (std::strerror (errno)); throw std::string (std::strerror (errno));
if (WIFEXITED (status)) if (WIFEXITED (status))
{ {
status = WEXITSTATUS (status); status = WEXITSTATUS (status);