*/
+#include <exception>
#include <memory.h>
#include <tests_common.h>
#include <temp_test_user.h>
int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
RUNNER_ASSERT_MSG(ret != -1, "socketpair() failed");
+ pid_t parent_pid = getpid();
pid_t pid = fork();
RUNNER_ASSERT_MSG(pid != -1, "fork() failed");
if (pid) { // parent
m_sock = sock[1];
close(sock[0]);
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); // Don't outlive parent process
+ // If the parent died before prctl(), we won't be SIGKILLed
+ if (parent_pid != getppid())
+ std::terminate();
run(); // Never returns
}
}
ret = TEMP_FAILURE_RETRY(
read(m_sock, static_cast<char *>(buf) + pos, cnt - pos));
RUNNER_ASSERT_MSG(ret != -1, "read() failed");
+ RUNNER_ASSERT_MSG(ret > 0, "expected " << cnt << " bytes, but read only " << pos
+ << " and the socket closed");
}
}