summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 9e58e4a..68e05ce 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -104,6 +104,16 @@ void xorg::testing::Environment::SetUp() {
static char display_string[6];
snprintf(display_string, 6, ":%d", d_->display);
+ Display* test_display = XOpenDisplay(display_string);
+ if (test_display) {
+ XCloseDisplay(test_display);
+ std::string message;
+ message += "A server is already running on ";
+ message += display_string;
+ message += ".";
+ throw std::runtime_error(message);
+ }
+
d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(),
display_string,
"-logfile", d_->path_to_log_file.c_str(),
@@ -113,7 +123,7 @@ void xorg::testing::Environment::SetUp() {
Process::SetEnv("DISPLAY", display_string, true);
for (int i = 0; i < 10; ++i) {
- Display* test_display = XOpenDisplay(NULL);
+ test_display = XOpenDisplay(NULL);
if (test_display) {
XCloseDisplay(test_display);