Commit 915d1c4d authored by Davi Arnaut's avatar Davi Arnaut

Fix warnings generated by SunStudio and GCC.

Based upon patch contributed by Stewart Smith
parent 7c28ec97
...@@ -89,7 +89,7 @@ static void die(const char* fmt, ...) ...@@ -89,7 +89,7 @@ static void die(const char* fmt, ...)
} }
static void kill_child (void) static void kill_child(void)
{ {
int status= 0; int status= 0;
...@@ -119,7 +119,7 @@ static void kill_child (void) ...@@ -119,7 +119,7 @@ static void kill_child (void)
} }
static void handle_abort (int sig) extern "C" void handle_abort(int sig)
{ {
message("Got signal %d, child_pid: %d, sending ABRT", sig, child_pid); message("Got signal %d, child_pid: %d, sending ABRT", sig, child_pid);
...@@ -128,8 +128,8 @@ static void handle_abort (int sig) ...@@ -128,8 +128,8 @@ static void handle_abort (int sig)
} }
} }
static void handle_signal (int sig) extern "C" void handle_signal(int sig)
{ {
message("Got signal %d, child_pid: %d", sig, child_pid); message("Got signal %d, child_pid: %d", sig, child_pid);
terminated= 1; terminated= 1;
...@@ -152,7 +152,7 @@ int main(int argc, char* const argv[] ) ...@@ -152,7 +152,7 @@ int main(int argc, char* const argv[] )
pid_t own_pid= getpid(); pid_t own_pid= getpid();
pid_t parent_pid= getppid(); pid_t parent_pid= getppid();
bool nocore = false; bool nocore = false;
/* Install signal handlers */ /* Install signal handlers */
signal(SIGTERM, handle_signal); signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal); signal(SIGINT, handle_signal);
...@@ -232,10 +232,11 @@ int main(int argc, char* const argv[] ) ...@@ -232,10 +232,11 @@ int main(int argc, char* const argv[] )
message("setrlimit failed, errno=%d", errno); message("setrlimit failed, errno=%d", errno);
} }
} }
// Signal that child is ready // Signal that child is ready
buf= 37; buf= 37;
write(pfd[1], &buf, 1); if ((write(pfd[1], &buf, 1)) < 1)
die("Failed to signal that child is ready");
// Close write end // Close write end
close(pfd[1]); close(pfd[1]);
...@@ -246,8 +247,10 @@ int main(int argc, char* const argv[] ) ...@@ -246,8 +247,10 @@ int main(int argc, char* const argv[] )
close(pfd[1]); // Close unused write end close(pfd[1]); // Close unused write end
// Wait for child to signal it's ready // Wait for child to signal it's ready
read(pfd[0], &buf, 1); if ((read(pfd[0], &buf, 1)) < 1)
if(buf != 37) die("Failed to read signal from child");
if (buf != 37)
die("Didn't get 37 from pipe"); die("Didn't get 37 from pipe");
close(pfd[0]); // Close read end close(pfd[0]); // Close read end
...@@ -272,7 +275,7 @@ int main(int argc, char* const argv[] ) ...@@ -272,7 +275,7 @@ int main(int argc, char* const argv[] )
if (WIFEXITED(status)) if (WIFEXITED(status))
{ {
// Process has exited, collect return status // Process has exited, collect return status
int ret_code= WEXITSTATUS(status); ret_code= WEXITSTATUS(status);
message("Child exit: %d", ret_code); message("Child exit: %d", ret_code);
// Exit with exit status of the child // Exit with exit status of the child
exit(ret_code); exit(ret_code);
...@@ -287,6 +290,6 @@ int main(int argc, char* const argv[] ) ...@@ -287,6 +290,6 @@ int main(int argc, char* const argv[] )
} }
kill_child(); kill_child();
exit(1); return 1;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment