XQuartz: Fixed a few issues with fd passing... still not working =(
(cherry picked from commit 7dd351271522b475d8017e4bd1618f12817ee2fa)
This commit is contained in:
parent
e837244947
commit
3a22190061
|
@ -163,10 +163,11 @@ static void accept_fd_handoff(int connected_fd) {
|
||||||
|
|
||||||
launchd_fd = *((int*)CMSG_DATA(cmsg));
|
launchd_fd = *((int*)CMSG_DATA(cmsg));
|
||||||
|
|
||||||
if(launchd_fd > 0)
|
if(launchd_fd == -1)
|
||||||
DarwinListenOnOpenFD(launchd_fd);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Error receiving $DISPLAY file descriptor, no descriptor received? %d\n", launchd_fd);
|
fprintf(stderr, "Error receiving $DISPLAY file descriptor, no descriptor received? %d\n", launchd_fd);
|
||||||
|
|
||||||
|
fprintf(stderr, "Received new DISPLAY fd: %d\n", launchd_fd);
|
||||||
|
DarwinListenOnOpenFD(launchd_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -227,9 +228,6 @@ static void socket_handoff_thread(void *arg) {
|
||||||
|
|
||||||
connected_fd = accept(handoff_fd, NULL, NULL);
|
connected_fd = accept(handoff_fd, NULL, NULL);
|
||||||
|
|
||||||
/* We delete this temporary socket after we get the connection */
|
|
||||||
unlink(filename);
|
|
||||||
|
|
||||||
if(connected_fd == -1) {
|
if(connected_fd == -1) {
|
||||||
fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", filename, strerror(errno));
|
fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", filename, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
@ -237,8 +235,10 @@ static void socket_handoff_thread(void *arg) {
|
||||||
|
|
||||||
/* Now actually get the passed file descriptor from this connection */
|
/* Now actually get the passed file descriptor from this connection */
|
||||||
accept_fd_handoff(connected_fd);
|
accept_fd_handoff(connected_fd);
|
||||||
|
|
||||||
|
close(connected_fd);
|
||||||
close(handoff_fd);
|
close(handoff_fd);
|
||||||
|
unlink(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
|
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void set_x11_path() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_fd_handoff(int connected_fd, int launchd_fd) {
|
static void send_fd_handoff(int handoff_fd, int launchd_fd) {
|
||||||
char databuf[] = "display";
|
char databuf[] = "display";
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
|
|
||||||
|
@ -143,19 +143,19 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
|
||||||
|
|
||||||
*((int*)CMSG_DATA(cmsg)) = launchd_fd;
|
*((int*)CMSG_DATA(cmsg)) = launchd_fd;
|
||||||
|
|
||||||
if (sendmsg(connected_fd, &msg, 0) < 0) {
|
if (sendmsg(handoff_fd, &msg, 0) < 0) {
|
||||||
fprintf(stderr, "Error sending $DISPLAY file descriptor: %s\n", strerror(errno));
|
fprintf(stderr, "Error sending $DISPLAY file descriptor: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "send %d %d %d %s\n", connected_fd, launchd_fd, errno, strerror(errno));
|
fprintf(stderr, "send %d %d %d %s\n", handoff_fd, launchd_fd, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handoff_fd(const char *filename, int launchd_fd) {
|
static void handoff_fd(const char *filename, int launchd_fd) {
|
||||||
struct sockaddr_un servaddr_un;
|
struct sockaddr_un servaddr_un;
|
||||||
struct sockaddr *servaddr;
|
struct sockaddr *servaddr;
|
||||||
socklen_t servaddr_len;
|
socklen_t servaddr_len;
|
||||||
int handoff_fd, connected_fd;
|
int handoff_fd;
|
||||||
|
|
||||||
/* Setup servaddr_un */
|
/* Setup servaddr_un */
|
||||||
memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
|
memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
|
||||||
|
@ -171,15 +171,14 @@ static void handoff_fd(const char *filename, int launchd_fd) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connected_fd = connect(handoff_fd, servaddr, servaddr_len);
|
if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
|
||||||
|
|
||||||
if(connected_fd == -1) {
|
|
||||||
fprintf(stderr, "Failed to establish connection on socket: %s - %s\n", filename, strerror(errno));
|
fprintf(stderr, "Failed to establish connection on socket: %s - %s\n", filename, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_fd_handoff(connected_fd, launchd_fd);
|
fprintf(stderr, "Socket: %s\n", filename);
|
||||||
|
|
||||||
|
send_fd_handoff(handoff_fd, launchd_fd);
|
||||||
close(handoff_fd);
|
close(handoff_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue