file descriptor manipulation

From: Shay Rojansky (roji@bezeqint.net)
Date: Wed Feb 09 2000 - 01:53:22 EST


Hi.

At some point I had a background process running and didn't have access to
its tty (accidentally closed the xterm). So I thought about writing a way
for a process's owner to directly control the process's file descriptor
table.

The idea is for a program to open some sort of file (say
/proc/<pid>/fdctl) and be able to say "replace <pid>'s third file
descriptor with my sixth file descriptor". The kernel would close <pid>'s
third file descriptor, and then make it point to the same file structure
as current's 6th pid.

This would be done by a user-level program (say 'fdctl') which we would
use to open an existing file and assign the file structure for that file
to any other process.

This can go the other way around - we could get a file descriptor pointing
to another running process's file structure, and be able to snoop on what
that process is doing with that file (to a very limited extent).

Again, the most useful feature that comes to mind is to assign a
background's process stdout to an xterm, but other applications might come
along.

I've already written part of this, and I was wondering whether someone has
already done it, or is interested. I am also not sure as to the /proc API
needed (writing to /proc/<pid>/fdctl? ioctl?)

Please cc to me as I'm not subscribed to the list... :)

---
Shay Rojansky

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:22 EST