summaryrefslogtreecommitdiffstats
path: root/tools/xdisplaycheck/xdisplaycheck.cc
diff options
context:
space:
mode:
authorpetermayo@chromium.org <petermayo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 00:14:26 +0000
committerpetermayo@chromium.org <petermayo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 00:14:26 +0000
commit14240b3aaf02da328ecb70031ab3f3c9fc2eee43 (patch)
treeb97feb1e840b94db9e55fcd4c9544202d82034d4 /tools/xdisplaycheck/xdisplaycheck.cc
parentde679fb3bf4d8aa1f6f0fcb08dddd7cefce41f0c (diff)
downloadchromium_src-14240b3aaf02da328ecb70031ab3f3c9fc2eee43.zip
chromium_src-14240b3aaf02da328ecb70031ab3f3c9fc2eee43.tar.gz
chromium_src-14240b3aaf02da328ecb70031ab3f3c9fc2eee43.tar.bz2
Add a mode to ensure a server is not already running.
BUG=128770 TEST=local positive, negative, and no argument. Review URL: https://chromiumcodereview.appspot.com/10409035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/xdisplaycheck/xdisplaycheck.cc')
-rw-r--r--tools/xdisplaycheck/xdisplaycheck.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/xdisplaycheck/xdisplaycheck.cc b/tools/xdisplaycheck/xdisplaycheck.cc
index 6c4c677..7bc99c5 100644
--- a/tools/xdisplaycheck/xdisplaycheck.cc
+++ b/tools/xdisplaycheck/xdisplaycheck.cc
@@ -12,6 +12,7 @@
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <time.h>
#include <X11/Xlib.h>
@@ -34,8 +35,19 @@ void Sleep(int duration_ms) {
}
int main(int argc, char* argv[]) {
- int kNumTries = 78; // 78*77/2 * 10 = 30s of waiting
Display* display = NULL;
+ if (argv[1] && strcmp(argv[1], "--noserver") == 0) {
+ display = XOpenDisplay(NULL);
+ if (display) {
+ fprintf(stderr, "Found unexpected connectable display %s\n",
+ XDisplayName(NULL));
+ }
+ // Return success when we got an unexpected display so that the code
+ // without the --noserver is the same, but slow, rather than inverted.
+ return !display;
+ }
+
+ int kNumTries = 78; // 78*77/2 * 10 = 30s of waiting
int tries;
for (tries = 0; tries < kNumTries; ++tries) {
display = XOpenDisplay(NULL);