XQuartz: More startup work... listen if we're the actual server

(cherry picked from commit 3b0afb47c3d8ad922cb2315ed8034f4d77d4a249)
This commit is contained in:
Jeremy Huddleston 2008-05-12 09:27:27 -07:00
parent a7800d9355
commit ac4e33a9cd

View File

@ -139,6 +139,9 @@ static void startup_trigger_thread(void *arg) {
int main(int argc, char **argv, char **envp) {
BOOL listenOnly = FALSE;
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++) {
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
* thread handle it.
*/
@ -160,17 +168,14 @@ int main(int argc, char **argv, char **envp) {
args->envp = envp;
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;
mach_port_t mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
kern_return_t kr;
if((argc > 1 && argv[1][0] == ':') || listenOnly) {
/* Main event loop */
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
if (kr != KERN_SUCCESS) {