Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preforker: prevent call to 'write' on an fd that was already closed, … #10949

Merged
merged 1 commit into from Sep 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/common/Preforker.h
Expand Up @@ -39,7 +39,7 @@ class Preforker {

int prefork(std::string &err) {
assert(!forked);
int r = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
int r = ::socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
std::ostringstream oss;
if (r < 0) {
oss << "[" << getpid() << "]: unable to create socketpair: " << cpp_strerror(errno);
Expand All @@ -56,7 +56,7 @@ class Preforker {
err = oss.str();
return r;
}
if (childpid == 0) {
if (is_child()) {
::close(fd[0]);
} else {
::close(fd[1]);
Expand Down Expand Up @@ -117,7 +117,8 @@ class Preforker {
return r;
}
void exit(int r) {
signal_exit(r);
if (is_child())
signal_exit(r);
::exit(r);
}

Expand Down