bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passfd on more platforms


From: Paolo Bonzini
Subject: Re: passfd on more platforms
Date: Mon, 14 Mar 2011 14:45:35 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 03/14/2011 02:36 PM, Bastien ROUCARIES wrote:
Or you could ask throught the socket, the process id of the receiving
process than send the handle.

Remember:
It is assumed that the two sides have coordinated and agreed to
transfer a file descriptor already, so that the sendfd is met with a
recvfd instead of an ordinary read.

No, you cannot unfortunately.  Say that process 1 will do this:

    send "getfd\n"
    sendfd

then the following will work on Unix in process 2:

    recv(socket, buf, 512) => return 6, buf = "getfd\n"
    parse getfd
    recvfd

If the recvfd info is sent on the normal channel (i.e. not out-of-band), process 2 is going to fail like this:

    recv(socket, buf, 512) => return 17, buf = "getfd\n0x12345678\0"
    parse getfd
    recvfd fails, or even worse it blocks (possibly forever)
    even if recvfd doesn't block, parsing 0x12345678\0 fails

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]