summaryrefslogtreecommitdiff
path: root/hw/xquartz/mach-startup/bundle-main.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-07-07 10:55:58 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-07-11 10:13:32 -0700
commit90dd2de845ae12153296f6f1bff0c87f79c57854 (patch)
tree3a008ab9fe808ae5f219f60e9e92b9f4e57e4579 /hw/xquartz/mach-startup/bundle-main.c
parent26d8030c3836816de8c12b2cb9d67315e5c887eb (diff)
XQuartz: Some fd handoff cleanup.
(cherry picked from commit 9c20a4804d97e67a988f00f49866997209cce518)
Diffstat (limited to 'hw/xquartz/mach-startup/bundle-main.c')
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index de92361e8..9894ae8b2 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -57,6 +57,8 @@ extern int noPanoramiXExtension;
#define DEFAULT_STARTX "/usr/X11/bin/startx"
#define DEFAULT_SHELL "/bin/sh"
+#define DEBUG 1
+
static int execute(const char *command);
static char *command_from_prefs(const char *key, const char *default_value);
@@ -198,8 +200,8 @@ static void socket_handoff_thread(void *arg) {
servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
handoff_fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if(handoff_fd == 0) {
- fprintf(stderr, "Failed to create socket: %s - %s\n", filename, strerror(errno));
+ if(handoff_fd == -1) {
+ fprintf(stderr, "X11.app: Failed to create socket: %d - %s\n", errno, strerror(errno));
data->retval = EXIT_FAILURE;
pthread_cond_broadcast(&data->cond);
@@ -213,7 +215,7 @@ static void socket_handoff_thread(void *arg) {
pthread_mutex_unlock(&data->lock);
if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
- fprintf(stderr, "Failed to connect to socket: %s - %s\n", filename, strerror(errno));
+ fprintf(stderr, "X11.app: Failed to connect to socket: %s - %d - %s\n", filename, errno, strerror(errno));
return;
}
@@ -226,6 +228,10 @@ static void socket_handoff_thread(void *arg) {
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
handoff_data_t handoff_data;
+#ifdef DEBUG
+ fprintf(stderr, "X11.app: Prepping for fd handoff.\n");
+#endif
+
/* Initialize our data */
pthread_mutex_init(&handoff_data.lock, NULL);
pthread_cond_init(&handoff_data.cond, NULL);
@@ -235,6 +241,10 @@ kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
create_thread(socket_handoff_thread, &handoff_data);
+#ifdef DEBUG
+ fprintf(stderr, "X11.app: Thread created for handoff. Waiting on return value.\n");
+#endif
+
/* Wait for our return value */
pthread_cond_wait(&handoff_data.cond, &handoff_data.lock);
pthread_mutex_unlock(&handoff_data.lock);
@@ -242,6 +252,10 @@ kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
/* Cleanup */
pthread_cond_destroy(&handoff_data.cond);
pthread_mutex_destroy(&handoff_data.lock);
+
+#ifdef DEBUG
+ fprintf(stderr, "X11.app: Sending return value: %d\n", handoff_data.retval);
+#endif
return handoff_data.retval;
}