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

Side by Side Diff: base/process/launch_win.cc

Issue 324493003: Another try at fixing --enable-logging on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/process/launch.h" 5 #include "base/process/launch.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <windows.h> 10 #include <windows.h>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // that case, we don't want to open CONOUT$, because its output 57 // that case, we don't want to open CONOUT$, because its output
58 // likely does not go anywhere. 58 // likely does not go anywhere.
59 // 59 //
60 // We don't use GetStdHandle() to check stdout/stderr here because 60 // We don't use GetStdHandle() to check stdout/stderr here because
61 // it can return dangling IDs of handles that were never inherited 61 // it can return dangling IDs of handles that were never inherited
62 // by this process. These IDs could have been reused by the time 62 // by this process. These IDs could have been reused by the time
63 // this function is called. The CRT checks the validity of 63 // this function is called. The CRT checks the validity of
64 // stdout/stderr on startup (before the handle IDs can be reused). 64 // stdout/stderr on startup (before the handle IDs can be reused).
65 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was 65 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was
66 // invalid. 66 // invalid.
67 if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) 67
68 // TODO(scottmg):
69 // Unfortunately _fileno was broken in VS2012, and is still broken in VS2013.
70 // https://connect.microsoft.com/VisualStudio/feedback/details/785119/
71 // http://crbug.com/358267
72 // It never returns -2 as it is documented to do (and per above) when in a
73 // windowed application without a console. As a result, we have to use
74 // GetStdHandle, even though it's not strictly correct. Hopefully this can
75 // be removed after a future revision of the CRT.
76 if ((_fileno(stdout) >= 0 && GetStdHandle(STD_OUTPUT_HANDLE) != NULL) ||
77 (_fileno(stderr) >= 0 && GetStdHandle(STD_ERROR_HANDLE)) != NULL)
68 return; 78 return;
69 79
70 if (!AttachConsole(ATTACH_PARENT_PROCESS)) { 80 if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
71 unsigned int result = GetLastError(); 81 unsigned int result = GetLastError();
72 // Was probably already attached. 82 // Was probably already attached.
73 if (result == ERROR_ACCESS_DENIED) 83 if (result == ERROR_ACCESS_DENIED)
74 return; 84 return;
75 // Don't bother creating a new console for each child process if the 85 // Don't bother creating a new console for each child process if the
76 // parent process is invalid (eg: crashed). 86 // parent process is invalid (eg: crashed).
77 if (result == ERROR_GEN_FAILURE) 87 if (result == ERROR_GEN_FAILURE)
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 WaitForSingleObject(proc_info.process_handle(), INFINITE); 372 WaitForSingleObject(proc_info.process_handle(), INFINITE);
363 373
364 return true; 374 return true;
365 } 375 }
366 376
367 void RaiseProcessToHighPriority() { 377 void RaiseProcessToHighPriority() {
368 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 378 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
369 } 379 }
370 380
371 } // namespace base 381 } // 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