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
parent de679fb3
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
...@@ -34,8 +35,19 @@ void Sleep(int duration_ms) { ...@@ -34,8 +35,19 @@ void Sleep(int duration_ms) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int kNumTries = 78; // 78*77/2 * 10 = 30s of waiting
Display* display = NULL; 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; int tries;
for (tries = 0; tries < kNumTries; ++tries) { for (tries = 0; tries < kNumTries; ++tries) {
display = XOpenDisplay(NULL); display = XOpenDisplay(NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment