XQuartz: More startup work... listen if we're the actual server
(cherry picked from commit 3b0afb47c3d8ad922cb2315ed8034f4d77d4a249)
This commit is contained in:
parent
a7800d9355
commit
ac4e33a9cd
|
@ -139,6 +139,9 @@ static void startup_trigger_thread(void *arg) {
|
||||||
int main(int argc, char **argv, char **envp) {
|
int main(int argc, char **argv, char **envp) {
|
||||||
BOOL listenOnly = FALSE;
|
BOOL listenOnly = FALSE;
|
||||||
int i;
|
int i;
|
||||||
|
mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
|
||||||
|
mach_port_t mp;
|
||||||
|
kern_return_t kr;
|
||||||
|
|
||||||
for(i=1; i < argc; i++) {
|
for(i=1; i < argc; i++) {
|
||||||
if(!strcmp(argv[i], "--listenonly")) {
|
if(!strcmp(argv[i], "--listenonly")) {
|
||||||
|
@ -147,6 +150,11 @@ int main(int argc, char **argv, char **envp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: This should be unconditional once we figure out fd passing */
|
||||||
|
if((argc > 1 && argv[1][0] == ':') || listenOnly) {
|
||||||
|
mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we need to do something other than listen, and make another
|
/* Check if we need to do something other than listen, and make another
|
||||||
* thread handle it.
|
* thread handle it.
|
||||||
*/
|
*/
|
||||||
|
@ -154,23 +162,20 @@ int main(int argc, char **argv, char **envp) {
|
||||||
struct arg *args = (struct arg*)malloc(sizeof(struct arg));
|
struct arg *args = (struct arg*)malloc(sizeof(struct arg));
|
||||||
if(!args)
|
if(!args)
|
||||||
FatalError("Could not allocate memory.\n");
|
FatalError("Could not allocate memory.\n");
|
||||||
|
|
||||||
args->argc = argc;
|
args->argc = argc;
|
||||||
args->argv = argv;
|
args->argv = argv;
|
||||||
args->envp = envp;
|
args->envp = envp;
|
||||||
|
|
||||||
create_thread(startup_trigger_thread, args);
|
create_thread(startup_trigger_thread, args);
|
||||||
} else {
|
}
|
||||||
/* TODO: This should actually fall through rather than be the else
|
|
||||||
* case once we figure out how to get the stub to pass the
|
|
||||||
* file descriptor. For now, we only listen if we are explicitly
|
|
||||||
* told to.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
|
/* TODO: This should actually fall through rather than be the else
|
||||||
mach_port_t mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
|
* case once we figure out how to get the stub to pass the
|
||||||
kern_return_t kr;
|
* file descriptor. For now, we only listen if we are explicitly
|
||||||
|
* told to.
|
||||||
|
*/
|
||||||
|
if((argc > 1 && argv[1][0] == ':') || listenOnly) {
|
||||||
/* Main event loop */
|
/* Main event loop */
|
||||||
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
|
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
|
@ -179,7 +184,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +213,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
return server_main(argc, argv, envp);
|
return server_main(argc, argv, envp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have a process serial number and it's our only arg, act as if
|
/* If we have a process serial number and it's our only arg, act as if
|
||||||
* the user double clicked the app bundle: launch app_to_run if possible
|
* the user double clicked the app bundle: launch app_to_run if possible
|
||||||
*/
|
*/
|
||||||
|
@ -227,7 +232,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
|
return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the server */
|
/* Start the server */
|
||||||
if((s = getenv("DISPLAY"))) {
|
if((s = getenv("DISPLAY"))) {
|
||||||
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
|
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
|
||||||
|
|
Loading…
Reference in New Issue