Skip to content

Commit

Permalink
XQuartz: unsetenv("DISPLAY") before startx if X11.app can't connect t…
Browse files Browse the repository at this point in the history
…o it.

Also fix casting to silence warning.
  • Loading branch information
Jeremy Huddleston committed Feb 19, 2008
1 parent 880a5cc commit a5cbf78
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hw/xquartz/bundle/bundle-main.c
Expand Up @@ -45,6 +45,7 @@ static char *command_from_prefs(const char *key, const char *default_value);

int main(int argc, char **argv) {
Display *display;
const char *s;

size_t i;
fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
Expand Down Expand Up @@ -72,7 +73,12 @@ int main(int argc, char **argv) {
}

/* Start the server */
fprintf(stderr, "X11.app: Could not connect to server. Starting X server.");
if(s = getenv("DISPLAY")) {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
unsetenv("DISPLAY");
} else {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
}
return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
}

Expand All @@ -93,7 +99,7 @@ static int execute(const char *command) {
fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
}

execvp (newargv[0], (const char **) newargv);
execvp (newargv[0], (char * const *) newargv);
perror ("X11.app: Couldn't exec.");
return(1);
}
Expand Down

0 comments on commit a5cbf78

Please sign in to comment.