On Mon, 30 Nov 2009 21:02:00 +1100, Daniel Dalton wrote: >> That did the trick, thanks, after I append >> [-2] > > Further testing under screen says otherwise -- it seems to give me the > tty number, not the virtual console number. Is there any way to figure > out what virtual console I'm am in
I'm sure that there are all kinds of heuristics you could try, but ultimately the question is meaningless. E.g. you can start a screen session on one terminal (which may not be a VC, but an xterm, ssh login, etc), detach it, attach it to a different terminal, or even attach it to multiple terminals. The child process only knows about its controlling terminal. If that happens to be a pty slave, you could try looking for any processes connected to the pty master. But you aren't guaranteeed to find any such processes; if a process is running under a different account, you won't be able to enumerate its descriptors. And you might find that the master is owned by e.g. sshd, in which case there really isn't any way to find out what's on the other end of the connection. If the process happens to be part of a "screen" session, you can use "screen -ls" to list sessions, and find out which terminal they are attached to (although they might be detached, or they might be attached to something other than a VC). -- http://mail.python.org/mailman/listinfo/python-list