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

Side by Side Diff: third_party/crashpad/crashpad/test/multiprocess_exec_test_child.cc

Issue 2478633002: Update Crashpad to b47bf6c250c6b825dee1c5fbad9152c2c962e828 (Closed)
Patch Set: mac comment 2 Created 4 years, 1 month 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 Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include <errno.h> 15 #include <errno.h>
16 #include <limits.h> 16 #include <limits.h>
17 #include <stdio.h> 17 #include <stdio.h>
18 #include <stdlib.h> 18 #include <stdlib.h>
19 #include <sys/types.h> 19 #include <sys/types.h>
20 20
21 #include <algorithm> 21 #include <algorithm>
22 22
23 #if defined(__APPLE__) || defined(__linux__) 23 #if defined(__APPLE__) || defined(__linux__)
24 #define OS_POSIX 1 24 #define OS_POSIX 1
25 #elif defined(_WIN32) 25 #elif defined(_WIN32)
26 #define OS_WIN 1 26 #define OS_WIN 1
27 #endif 27 #endif
28 28
29 #if defined(OS_POSIX) 29 #if defined(OS_POSIX)
30 #include <sys/resource.h>
30 #include <unistd.h> 31 #include <unistd.h>
31 #elif defined(OS_WIN) 32 #elif defined(OS_WIN)
32 #include <windows.h> 33 #include <windows.h>
33 #endif 34 #endif
34 35
35 int main(int argc, char* argv[]) { 36 int main(int argc, char* argv[]) {
36 #if defined(OS_POSIX) 37 #if defined(OS_POSIX)
37 // Make sure that there’s nothing open at any FD higher than 3. All FDs other 38 // Make sure that there’s nothing open at any FD higher than 3. All FDs other
38 // than stdin, stdout, and stderr should have been closed prior to or at 39 // than stdin, stdout, and stderr should have been closed prior to or at
39 // exec(). 40 // exec().
40 int max_fd = std::max(static_cast<int>(sysconf(_SC_OPEN_MAX)), OPEN_MAX); 41 rlimit rlimit_nofile;
41 max_fd = std::max(max_fd, getdtablesize()); 42 if (getrlimit(RLIMIT_NOFILE, &rlimit_nofile) != 0) {
42 for (int fd = STDERR_FILENO + 1; fd < max_fd; ++fd) { 43 abort();
44 }
45 for (int fd = STDERR_FILENO + 1;
46 fd < static_cast<int>(rlimit_nofile.rlim_cur);
47 ++fd) {
43 if (close(fd) == 0 || errno != EBADF) { 48 if (close(fd) == 0 || errno != EBADF) {
44 abort(); 49 abort();
45 } 50 }
46 } 51 }
47 52
48 // Read a byte from stdin, expecting it to be a specific value. 53 // Read a byte from stdin, expecting it to be a specific value.
49 char c; 54 char c;
50 ssize_t rv = read(STDIN_FILENO, &c, 1); 55 ssize_t rv = read(STDIN_FILENO, &c, 1);
51 if (rv != 1 || c != 'z') { 56 if (rv != 1 || c != 'z') {
52 abort(); 57 abort();
(...skipping 22 matching lines...) Expand all
75 DWORD bytes_written; 80 DWORD bytes_written;
76 if (!WriteFile( 81 if (!WriteFile(
77 GetStdHandle(STD_OUTPUT_HANDLE), &c, 1, &bytes_written, nullptr) || 82 GetStdHandle(STD_OUTPUT_HANDLE), &c, 1, &bytes_written, nullptr) ||
78 bytes_written != 1) { 83 bytes_written != 1) {
79 abort(); 84 abort();
80 } 85 }
81 #endif // OS_POSIX 86 #endif // OS_POSIX
82 87
83 return 0; 88 return 0;
84 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698