Fix warnings generated by SunStudio and GCC.
Based upon patch contributed by Stewart Smith mysql-test/lib/My/SafeProcess/safe_process.cc: Fix style -- remove unneeded spaces. Specify C linkage for the signal handling functions. Check return value from read()/write().
This commit is contained in:
parent
ead1ce94e6
commit
a56ab623ba
@ -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);
|
||||
|
||||
@ -129,7 +129,7 @@ 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);
|
||||
terminated= 1;
|
||||
@ -235,7 +235,8 @@ int main(int argc, char* const argv[] )
|
||||
|
||||
// Signal that child is ready
|
||||
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(pfd[1]);
|
||||
|
||||
@ -246,7 +247,9 @@ int main(int argc, char* const argv[] )
|
||||
close(pfd[1]); // Close unused write end
|
||||
|
||||
// Wait for child to signal it's ready
|
||||
read(pfd[0], &buf, 1);
|
||||
if ((read(pfd[0], &buf, 1)) < 1)
|
||||
die("Failed to read signal from child");
|
||||
|
||||
if (buf != 37)
|
||||
die("Didn't get 37 from pipe");
|
||||
close(pfd[0]); // Close read end
|
||||
@ -272,7 +275,7 @@ int main(int argc, char* const argv[] )
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
// Process has exited, collect return status
|
||||
int ret_code= WEXITSTATUS(status);
|
||||
ret_code= WEXITSTATUS(status);
|
||||
message("Child exit: %d", ret_code);
|
||||
// Exit with exit status of the child
|
||||
exit(ret_code);
|
||||
@ -287,6 +290,6 @@ int main(int argc, char* const argv[] )
|
||||
}
|
||||
kill_child();
|
||||
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user