Redirect relaunch process's stdout to /dev/null
This commit is contained in:
parent
08491e1ceb
commit
2ed733fedc
1 changed files with 8 additions and 0 deletions
|
@ -79,8 +79,16 @@ void RelauncherSynchronizeWithParent() {
|
||||||
|
|
||||||
int LaunchProgram(const StringVector& relauncher_args,
|
int LaunchProgram(const StringVector& relauncher_args,
|
||||||
const StringVector& argv) {
|
const StringVector& argv) {
|
||||||
|
// Redirect the stdout of child process to /dev/null, otherwise after
|
||||||
|
// relaunch the child process will raise exception when writing to stdout.
|
||||||
|
base::ScopedFD devnull(HANDLE_EINTR(open("/dev/null", O_WRONLY)));
|
||||||
|
base::FileHandleMappingVector no_stdout;
|
||||||
|
no_stdout.push_back(std::make_pair(devnull.get(), STDERR_FILENO));
|
||||||
|
no_stdout.push_back(std::make_pair(devnull.get(), STDOUT_FILENO));
|
||||||
|
|
||||||
base::LaunchOptions options;
|
base::LaunchOptions options;
|
||||||
options.new_process_group = true; // detach
|
options.new_process_group = true; // detach
|
||||||
|
options.fds_to_remap = &no_stdout;
|
||||||
base::Process process = base::LaunchProcess(argv, options);
|
base::Process process = base::LaunchProcess(argv, options);
|
||||||
return process.IsValid() ? 0 : 1;
|
return process.IsValid() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue