[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
passing a terminal's fd
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: passing a terminal's fd
- From: Vincent Labrecque <limitln_(_at_)_cooptel_(_dot_)_qc_(_dot_)_ca>
- Date: Sun, 1 Jul 2001 21:39:28 -0500
I realize it's not OpenBSD specific, but I run OpenBSD and somebody
in here must know.
Basically, what I want to do is that a client passes a file
descriptor of its terminal to a server so the server has further
access on this terminal, even after the client quits. I realize
this has multiple problems, notably that the terminal will stay open
as long as the daemon stays on (well, I _think_ so), and blah blah
blah. But I still want to do it.
What I tried is :
connect(destfd, [... to server's unix socket ...]);
fd = open("/dev/tty", O_RDWR); /* get my own tty */
send_fd(destfd, fd); /* FD passing using sendmsg() ... */
(and send_fd(destfd, fileno(stdout)), with the same result)
But it doesn't work. What I think is that they share the same file
descriptor entry, but it points to /dev/tty's vnode, which is
dynamic and always is the process' own console. (anyways, that's
what reading the code in /sys make me think).
Anybody has an idea of what I could try next? Even just a pointer
to where I could look...
I _could_ keep the clients in the background, writing on the
terminal and reading data from the server on a socket, but for
multiple reasons I would prefer not to.
Note: I'm not subscribed on misc@, so please CC answers to me.
Vincent Labrecque ASCII Ribbon /~\
Campaign Against \ /
limitln_(_at_)_cooptel_(_dot_)_qc_(_dot_)_ca HTML Email! X
http://www.cooptel.qc.ca/~limitln / \
Visit your host, monkey.org