… | |
… | |
33 | |
33 | |
34 | #ifndef CMSG_LEN // CMSG_SPACe && CMSG_LEN are rfc2292 extensions to unix |
34 | #ifndef CMSG_LEN // CMSG_SPACe && CMSG_LEN are rfc2292 extensions to unix |
35 | # define CMSG_LEN(len) (sizeof (cmsghdr) + len) |
35 | # define CMSG_LEN(len) (sizeof (cmsghdr) + len) |
36 | #endif |
36 | #endif |
37 | |
37 | |
38 | int |
38 | bool |
39 | ptytty::send_fd (int socket, int fd) |
39 | ptytty::send_fd (int socket, int fd) |
40 | { |
40 | { |
41 | msghdr msg; |
41 | msghdr msg; |
42 | iovec iov; |
42 | iovec iov; |
43 | char buf [CMSG_LEN (sizeof (int))]; |
43 | char buf [CMSG_LEN (sizeof (int))]; |
… | |
… | |
60 | |
60 | |
61 | *(int *)CMSG_DATA (cmsg) = fd; |
61 | *(int *)CMSG_DATA (cmsg) = fd; |
62 | |
62 | |
63 | msg.msg_controllen = cmsg->cmsg_len; |
63 | msg.msg_controllen = cmsg->cmsg_len; |
64 | |
64 | |
65 | return sendmsg (socket, &msg, 0); |
65 | return sendmsg (socket, &msg, 0) >= 0; |
66 | } |
66 | } |
67 | |
67 | |
68 | int |
68 | int |
69 | ptytty::recv_fd (int socket) |
69 | ptytty::recv_fd (int socket) |
70 | { |
70 | { |