b525469aae
This makes gnome-terminal actually work on PowerPC...
55 lines
1.3 KiB
Text
55 lines
1.3 KiB
Text
$NetBSD: patch-ap,v 1.1 2000/11/11 02:07:57 mycroft Exp $
|
|
|
|
--- zvt/subshell.c.orig Sat Nov 11 01:59:48 2000
|
|
+++ zvt/subshell.c Sat Nov 11 01:59:11 2000
|
|
@@ -101,32 +101,43 @@
|
|
#endif
|
|
#endif /* CMSG_DATA */
|
|
|
|
-static struct cmsghdr *cmptr;
|
|
-#define CONTROLLEN sizeof (struct cmsghdr) + sizeof (int)
|
|
+#define FD_LEN (sizeof(int) * 1)
|
|
+
|
|
+static void *cmptr;
|
|
|
|
static int
|
|
receive_fd (int helper_fd)
|
|
{
|
|
struct iovec iov [1];
|
|
struct msghdr msg;
|
|
+ struct cmsghdr *cmp;
|
|
char buf [32];
|
|
|
|
+ if (cmptr == NULL && (cmptr = g_malloc (CMSG_SPACE(FD_LEN))) == NULL)
|
|
+ return -1;
|
|
+
|
|
iov [0].iov_base = buf;
|
|
iov [0].iov_len = sizeof (buf);
|
|
+
|
|
+ memset(&msg, 0, sizeof(msg));
|
|
msg.msg_iov = iov;
|
|
msg.msg_iovlen = 1;
|
|
msg.msg_name = NULL;
|
|
msg.msg_namelen = 0;
|
|
-
|
|
- if (cmptr == NULL && (cmptr = g_malloc (CONTROLLEN)) == NULL)
|
|
- return -1;
|
|
msg.msg_control = (caddr_t) cmptr;
|
|
- msg.msg_controllen = CONTROLLEN;
|
|
+ msg.msg_controllen = CMSG_LEN(FD_LEN);
|
|
|
|
+ memset(cmptr, 0, CMSG_SPACE(FD_LEN));
|
|
if (recvmsg (helper_fd, &msg, 0) <= 0)
|
|
return -1;
|
|
|
|
- return *(int *) CMSG_DATA (cmptr);
|
|
+ for (cmp = CMSG_FIRSTHDR(&msg); cmp != NULL;
|
|
+ cmp = CMSG_NXTHDR(&msg, cmp)) {
|
|
+ if (cmp->cmsg_type == SCM_RIGHTS)
|
|
+ return *(int *) CMSG_DATA (cmp);
|
|
+ }
|
|
+
|
|
+ return -1;
|
|
}
|
|
|
|
static int
|