From 2ed733fedcea3b72fc146eae6eef31916c6bcba2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 18 Jul 2016 08:46:01 -0600 Subject: [PATCH] Redirect relaunch process's stdout to /dev/null --- atom/browser/relauncher_mac.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/atom/browser/relauncher_mac.cc b/atom/browser/relauncher_mac.cc index ac4c874c560d..6e288502455b 100644 --- a/atom/browser/relauncher_mac.cc +++ b/atom/browser/relauncher_mac.cc @@ -79,8 +79,16 @@ void RelauncherSynchronizeWithParent() { int LaunchProgram(const StringVector& relauncher_args, 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; options.new_process_group = true; // detach + options.fds_to_remap = &no_stdout; base::Process process = base::LaunchProcess(argv, options); return process.IsValid() ? 0 : 1; }