|
@@ -36,14 +36,14 @@ TEST(FDShare, transfer) {
|
|
|
// Get a pipe and fork
|
|
|
int pipes[2];
|
|
|
ASSERT_NE(-1, socketpair(AF_UNIX, SOCK_STREAM, 0, pipes));
|
|
|
- pid_t sender(fork());
|
|
|
+ const pid_t sender(fork());
|
|
|
ASSERT_NE(-1, sender);
|
|
|
- if(sender) { // We are in parent
|
|
|
+ if (sender) { // We are in parent
|
|
|
// Close the other side of pipe, we want only writible one
|
|
|
EXPECT_NE(-1, close(pipes[0]));
|
|
|
// Get a process to check data
|
|
|
int fd(0);
|
|
|
- pid_t checker(check_output(&fd, "data", 4));
|
|
|
+ const pid_t checker(check_output(&fd, "data", 4));
|
|
|
ASSERT_NE(-1, checker);
|
|
|
// Now, send the file descriptor, close it and close the pipe
|
|
|
EXPECT_NE(-1, send_fd(pipes[1], fd));
|
|
@@ -54,20 +54,20 @@ TEST(FDShare, transfer) {
|
|
|
EXPECT_TRUE(process_ok(checker));
|
|
|
} else { // We are in child. We do not use ASSERT here
|
|
|
// Close the write end, we only read
|
|
|
- if(close(pipes[1])) {
|
|
|
+ if (close(pipes[1])) {
|
|
|
exit(1);
|
|
|
}
|
|
|
// Get the file descriptor
|
|
|
- int fd(recv_fd(pipes[0]));
|
|
|
- if(fd == -1) {
|
|
|
+ const int fd(recv_fd(pipes[0]));
|
|
|
+ if (fd == -1) {
|
|
|
exit(1);
|
|
|
}
|
|
|
// This pipe is not needed
|
|
|
- if(close(pipes[0])) {
|
|
|
+ if (close(pipes[0])) {
|
|
|
exit(1);
|
|
|
}
|
|
|
// Send "data" trough the received fd, close it and be done
|
|
|
- if(!write_data(fd, "data", 4) || close(fd) == -1) {
|
|
|
+ if (!write_data(fd, "data", 4) || close(fd) == -1) {
|
|
|
exit(1);
|
|
|
}
|
|
|
exit(0);
|