mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-12-23 04:45:29 +00:00
FD leaks and handle errors better.
Patch from Matthew Dempsky <mdempsky@chromium.org>. Original review: https://breakpad.appspot.com/5654002/ Review URL: https://breakpad.appspot.com/1674002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1326 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
a789d1d26b
commit
40cd690901
|
@ -74,8 +74,10 @@ class CrashGenerationClientImpl : public CrashGenerationClient {
|
||||||
|
|
||||||
ssize_t ret = HANDLE_EINTR(sys_sendmsg(server_fd_, &msg, 0));
|
ssize_t ret = HANDLE_EINTR(sys_sendmsg(server_fd_, &msg, 0));
|
||||||
sys_close(fds[1]);
|
sys_close(fds[1]);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
|
sys_close(fds[0]);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for an ACK from the server.
|
// Wait for an ACK from the server.
|
||||||
char b;
|
char b;
|
||||||
|
|
|
@ -474,19 +474,25 @@ bool ExceptionHandler::GenerateDump(CrashContext *context) {
|
||||||
logger::write(no_pipe_msg, sizeof(no_pipe_msg) - 1);
|
logger::write(no_pipe_msg, sizeof(no_pipe_msg) - 1);
|
||||||
logger::write(strerror(errno), strlen(strerror(errno)));
|
logger::write(strerror(errno), strlen(strerror(errno)));
|
||||||
logger::write("\n", 1);
|
logger::write("\n", 1);
|
||||||
|
|
||||||
|
// Ensure fdes[0] and fdes[1] are invalid file descriptors.
|
||||||
|
fdes[0] = fdes[1] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pid_t child = sys_clone(
|
const pid_t child = sys_clone(
|
||||||
ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED,
|
ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED,
|
||||||
&thread_arg, NULL, NULL, NULL);
|
&thread_arg, NULL, NULL, NULL);
|
||||||
|
if (child == -1) {
|
||||||
|
sys_close(fdes[0]);
|
||||||
|
sys_close(fdes[1]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int r, status;
|
|
||||||
// Allow the child to ptrace us
|
// Allow the child to ptrace us
|
||||||
sys_prctl(PR_SET_PTRACER, child, 0, 0, 0);
|
sys_prctl(PR_SET_PTRACER, child, 0, 0, 0);
|
||||||
SendContinueSignalToChild();
|
SendContinueSignalToChild();
|
||||||
do {
|
int status;
|
||||||
r = sys_waitpid(child, &status, __WALL);
|
const int r = HANDLE_EINTR(sys_waitpid(child, &status, __WALL));
|
||||||
} while (r == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
sys_close(fdes[0]);
|
sys_close(fdes[0]);
|
||||||
sys_close(fdes[1]);
|
sys_close(fdes[1]);
|
||||||
|
|
Loading…
Reference in a new issue