From: K-mart Cashier on
Both Machine A and Machine B run FreeBSD. I telnet into machine B from
Machine A.

Now let's say I have a program running on Machine B. How would I send
an open fd from Machine A to Machine B? I'm kind of aware of passing
the fd. However, that only seems to work on the same machine.
From: Ben Finney on
K-mart Cashier <cdalten(a)gmail.com> writes:

> Now let's say I have a program running on Machine B. How would I send
> an open fd from Machine A to Machine B?

A file descriptor is simply an integer. However, it is unique only
within a single process running on a single machine.

What would you expect to be able to do with the file descriptor on
machine B?

--
\ “To save the world requires faith and courage: faith in reason, |
`\ and courage to proclaim what reason shows to be true.” |
_o__) —Bertrand Russell |
Ben Finney
From: Ersek, Laszlo on
In article <b0b6665e-d81c-40ef-889b-03c1caa35adb(a)s33g2000prm.googlegroups.com>, K-mart Cashier <cdalten(a)gmail.com> writes:
> Both Machine A and Machine B run FreeBSD. I telnet into machine B from
> Machine A.
>
> Now let's say I have a program running on Machine B. How would I send
> an open fd from Machine A to Machine B? I'm kind of aware of passing
> the fd. However, that only seems to work on the same machine.

Suppose the fd on Machine A refers to a regular file. Suppose you send
it over to Machine B. How is Machine B supposed to access the blocks of
the file residing on Machine A?

Suppose the fd on Machine A refers to a connected TCP socket (the peer
being Machine C). Once the fd is sent over to Machine B, what peer IP
address will Machine C see, as it was talking to Machine A up to that
point?

Suppose the fd on Machine A refers to a (connected) pipe... etc.

In summary, you can't, because the fd refers to objects living in
Machine A's kernel, and in the TCP socket case, the fd is indirectly
tied to Machine C's TCP control block and the underlying network
infrastructure. It wouldn't be enough to simply copy over the TCP
sequence numbers, ports and IP addresses, the routing rules would have
to be updated on nodes between Machine B and C. Furthermore, "passing an
fd" actually means an inter-process dup(), which allows the original
owner to continue using the fd. That would result in a three-pronged TCP
"connection" between {A,B} and C.

You can't pass the fd because you can't fork() a child in Machine A onto
Machine B.

Cheers,
lacos
From: David Schwartz on
On Feb 4, 4:48 pm, K-mart Cashier <cdal...(a)gmail.com> wrote:

> Now let's say I have a program running on Machine B. How would I send
> an open fd from Machine A to Machine B? I'm kind of aware of passing
> the fd. However, that only seems to work on the same machine.

You will have to decide exactly what you think that means and
implement that. It's clear what that means between two processes on
the same kernel. They're talking to the same kernel, so when the first
process does a 'read' to its kernel, the second process doing a read
will be to the same 'kernel', so it's clear how it can access the same
file, pipe, connection, or what have you.

But it's really not clear what that would mean between two different
machines. What would happen if B did a 'read' operation on a fd it got
from machine A? How do you expect that 'read' to get to A's kernel?

DS
From: Chris Friesen on
On 02/04/2010 07:05 PM, Ben Finney wrote:

> A file descriptor is simply an integer. However, it is unique only
> within a single process running on a single machine.

There is an exception--you can pass file descriptors between processes
via a unix socket. This is still on the same machine though.

Chris