为什么ancil_send_fd(发送fd)与ancil_recv_fd(receivefd)之间的fd不同?

时间:2017-05-18 04:12:47

标签: c++ c

这是lib辅助测试,为什么parent_process发送1,2,但是child_process接收是3,5?

按照代码,这是lib辅助测试:

void child_process(int sock)
{
    int fds[3], nfds;

    //rece fd is 3,5
    nfds = ancil_recv_fds(sock, fds, 3);
    if(nfds < 0) {
        perror("ancil_recv_fds");
        exit(1);
    }
}

void parent_process(int sock)
{
    int fds[2] = { 1, 2 };

    if(ancil_send_fds(sock, fds, 2)) {
        perror("ancil_send_fds");
        exit(1);
    } 
}

0 个答案:

没有答案