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

Side by Side Diff: sandbox/linux/services/thread_helpers.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/linux/services/thread_helpers.h" 5 #include "sandbox/linux/services/thread_helpers.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 25 matching lines...) Expand all
36 // determining if the current proces is monothreaded it works: if at any 36 // determining if the current proces is monothreaded it works: if at any
37 // time it becomes monothreaded, it'll stay so. 37 // time it becomes monothreaded, it'll stay so.
38 return task_stat.st_nlink == 3; 38 return task_stat.st_nlink == 3;
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 bool ThreadHelpers::IsSingleThreaded(int proc_self_task) { 43 bool ThreadHelpers::IsSingleThreaded(int proc_self_task) {
44 DCHECK_LE(-1, proc_self_task); 44 DCHECK_LE(-1, proc_self_task);
45 if (-1 == proc_self_task) { 45 if (-1 == proc_self_task) {
46 const int task_fd = open("/proc/self/task/", O_RDONLY | O_DIRECTORY); 46 const int task_fd =
47 open("/proc/self/task/", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
47 PCHECK(0 <= task_fd); 48 PCHECK(0 <= task_fd);
48 const bool result = IsSingleThreadedImpl(task_fd); 49 const bool result = IsSingleThreadedImpl(task_fd);
49 PCHECK(0 == IGNORE_EINTR(close(task_fd))); 50 PCHECK(0 == IGNORE_EINTR(close(task_fd)));
50 return result; 51 return result;
51 } else { 52 } else {
52 return IsSingleThreadedImpl(proc_self_task); 53 return IsSingleThreadedImpl(proc_self_task);
53 } 54 }
54 } 55 }
55 56
56 bool ThreadHelpers::StopThreadAndWatchProcFS(int proc_self_task, 57 bool ThreadHelpers::StopThreadAndWatchProcFS(int proc_self_task,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // In practice, this never goes through more than a couple iterations. In 94 // In practice, this never goes through more than a couple iterations. In
94 // debug mode, crash after 64ms (+ eventually 25 times the granularity of 95 // debug mode, crash after 64ms (+ eventually 25 times the granularity of
95 // the clock) in nanosleep(2). 96 // the clock) in nanosleep(2).
96 DCHECK_GT(25U, iterations); 97 DCHECK_GT(25U, iterations);
97 } 98 }
98 99
99 return true; 100 return true;
100 } 101 }
101 102
102 } // namespace sandbox 103 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/syscall_wrappers.cc ('k') | sandbox/linux/syscall_broker/broker_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698