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

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 155796: Make standard input /dev/null when running xdg-settings to set the default browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_linux.cc
===================================================================
--- chrome/browser/shell_integration_linux.cc (revision 21115)
+++ chrome/browser/shell_integration_linux.cc (working copy)
@@ -4,7 +4,11 @@
#include "chrome/browser/shell_integration.h"
+#include <fcntl.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <vector>
@@ -28,12 +32,26 @@
argv.push_back("default-web-browser");
argv.push_back(DESKTOP_APP_NAME);
- int success_code;
+ // xdg-settings internally runs xdg-mime, which uses mv to move newly-created
+ // files on top of originals after making changes to them. In the event that
+ // the original files are owned by another user (e.g. root, which can happen
+ // if they are updated within sudo), mv will prompt the user to confirm if
+ // standard input is a terminal (otherwise it just does it). So make sure it's
+ // not, to avoid locking everything up waiting for mv.
+ int devnull = open("/dev/null", O_RDONLY);
+ if (devnull < 0)
+ return false;
+ base::file_handle_mapping_vector no_stdin;
+ no_stdin.push_back(std::make_pair(devnull, STDIN_FILENO));
+
base::ProcessHandle handle;
- base::file_handle_mapping_vector no_files;
- if (!base::LaunchApp(argv, no_files, false, &handle))
+ if (!base::LaunchApp(argv, no_stdin, false, &handle)) {
+ close(devnull);
return false;
+ }
+ close(devnull);
+ int success_code;
base::WaitForExitCode(handle, &success_code);
return success_code == EXIT_SUCCESS;
}
« 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