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

Unified Diff: base/process/launch_posix.cc

Issue 21415003: Block signals while forking so they aren't run in the child process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert no-longer-needed kSignalsToReset refactoring Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/launch_posix.cc
diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc
index 3708af6bac417b49e4015fed93eb49966ed78363..1388a0e1524bef2dc57c981025b25fe7ae915dcd 100644
--- a/base/process/launch_posix.cc
+++ b/base/process/launch_posix.cc
@@ -394,6 +394,14 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (options.environ)
new_environ.reset(AlterEnvironment(*options.environ, GetEnvironment()));
+ sigset_t full_sigset;
+ sigfillset(&full_sigset);
+ sigset_t old_sigset;
+ if (pthread_sigmask(SIG_BLOCK, &full_sigset, &old_sigset) != 0) {
Markus (顧孟勤) 2013/08/01 01:20:54 In principle, I believe this works OK. But you are
Markus (顧孟勤) 2013/08/01 01:20:54 And now for a nitpick: It is actually not possibl
mdempsky_google 2013/08/01 16:25:05 https://code.google.com/p/chromium/issues/detail?i
mdempsky_google 2013/08/01 16:25:05 I expect sigfillset() + pthread_sigmask() should b
+ DPLOG(ERROR) << "pthread_sigmask";
+ return false;
+ }
+
pid_t pid;
#if defined(OS_LINUX)
if (options.clone_flags) {
@@ -404,6 +412,12 @@ bool LaunchProcess(const std::vector<std::string>& argv,
pid = fork();
}
+ if (pid != 0) {
+ if (pthread_sigmask(SIG_SETMASK, &old_sigset, NULL) != 0) {
+ NOTREACHED();
+ }
+ }
+
if (pid < 0) {
DPLOG(ERROR) << "fork";
return false;
@@ -469,6 +483,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
#endif // defined(OS_MACOSX)
ResetChildSignalHandlersToDefaults();
+ if (pthread_sigmask(SIG_SETMASK, &old_sigset, NULL) != 0) {
+ NOTREACHED();
+ }
#if 0
// When debugging it can be helpful to check that we really aren't making
« 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