Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: base/process_util_posix.cc

Issue 1801007: POSIX: catch more crash-indicating signals for in-process crash dumping. (Closed)
Patch Set: add SIGSYS back Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <dirent.h> 5 #include <dirent.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 } 96 }
97 97
98 if (success) 98 if (success)
99 *success = (ret_pid != -1); 99 *success = (ret_pid != -1);
100 100
101 return status; 101 return status;
102 } 102 }
103 103
104 void StackDumpSignalHandler(int signal) { 104 void StackDumpSignalHandler(int signal) {
105 LOG(ERROR) << "Received signal " << signal;
105 StackTrace().PrintBacktrace(); 106 StackTrace().PrintBacktrace();
106 _exit(1); 107 _exit(1);
107 } 108 }
108 109
109 } // anonymous namespace 110 } // anonymous namespace
110 111
111 ProcessId GetCurrentProcId() { 112 ProcessId GetCurrentProcId() {
112 return getpid(); 113 return getpid();
113 } 114 }
114 115
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 bool EnableInProcessStackDumping() { 586 bool EnableInProcessStackDumping() {
586 // When running in an application, our code typically expects SIGPIPE 587 // When running in an application, our code typically expects SIGPIPE
587 // to be ignored. Therefore, when testing that same code, it should run 588 // to be ignored. Therefore, when testing that same code, it should run
588 // with SIGPIPE ignored as well. 589 // with SIGPIPE ignored as well.
589 struct sigaction action; 590 struct sigaction action;
590 action.sa_handler = SIG_IGN; 591 action.sa_handler = SIG_IGN;
591 action.sa_flags = 0; 592 action.sa_flags = 0;
592 sigemptyset(&action.sa_mask); 593 sigemptyset(&action.sa_mask);
593 bool success = (sigaction(SIGPIPE, &action, NULL) == 0); 594 bool success = (sigaction(SIGPIPE, &action, NULL) == 0);
594 595
595 // TODO(phajdan.jr): Catch other crashy signals, like SIGABRT. 596 success &= (signal(SIGILL, &StackDumpSignalHandler) != SIG_ERR);
597 success &= (signal(SIGABRT, &StackDumpSignalHandler) != SIG_ERR);
598 success &= (signal(SIGFPE, &StackDumpSignalHandler) != SIG_ERR);
599 success &= (signal(SIGBUS, &StackDumpSignalHandler) != SIG_ERR);
596 success &= (signal(SIGSEGV, &StackDumpSignalHandler) != SIG_ERR); 600 success &= (signal(SIGSEGV, &StackDumpSignalHandler) != SIG_ERR);
597 success &= (signal(SIGILL, &StackDumpSignalHandler) != SIG_ERR); 601 success &= (signal(SIGSYS, &StackDumpSignalHandler) != SIG_ERR);
598 success &= (signal(SIGBUS, &StackDumpSignalHandler) != SIG_ERR); 602
599 success &= (signal(SIGFPE, &StackDumpSignalHandler) != SIG_ERR);
600 return success; 603 return success;
601 } 604 }
602 605
603 void AttachToConsole() { 606 void AttachToConsole() {
604 // On POSIX, there nothing to do AFAIK. Maybe create a new console if none 607 // On POSIX, there nothing to do AFAIK. Maybe create a new console if none
605 // exist? 608 // exist?
606 } 609 }
607 610
608 void RaiseProcessToHighPriority() { 611 void RaiseProcessToHighPriority() {
609 // On POSIX, we don't actually do anything here. We could try to nice() or 612 // On POSIX, we don't actually do anything here. We could try to nice() or
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 const ProcessFilter* filter) { 876 const ProcessFilter* filter) {
874 bool exited_cleanly = 877 bool exited_cleanly =
875 WaitForProcessesToExit(executable_name, wait_milliseconds, 878 WaitForProcessesToExit(executable_name, wait_milliseconds,
876 filter); 879 filter);
877 if (!exited_cleanly) 880 if (!exited_cleanly)
878 KillProcesses(executable_name, exit_code, filter); 881 KillProcesses(executable_name, exit_code, filter);
879 return exited_cleanly; 882 return exited_cleanly;
880 } 883 }
881 884
882 } // namespace base 885 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698