LWN.net Logo

Changing standard Input and Output to a different virtual Terminal.

Changing standard Input and Output to a different virtual Terminal.

Posted Nov 30, 2012 15:29 UTC (Fri) by gjw (guest, #130)
Parent article: LCE: Checkpoint/restore in user space: are we there yet?

Is it possible to change the files 0, 1, and 2
in the directory /proc/PID/fd ?

I want to change stdin, stdout and stderr
of a stopped process to a different Terminal...

Maybe checkpoint/restore can help to achieve this.
Changing the files even as root is impossible...


(Log in to post comments)

Changing standard Input and Output to a different virtual Terminal.

Posted Nov 30, 2012 17:40 UTC (Fri) by nybble41 (subscriber, #55106) [Link]

In principle, I think you could already do this to a running process (without root, even) by attaching a debugger:

$ gdb
(gdb) attach $pid
...
(gdb) call close(1)
$1 = 0
(gdb) call open("/dev/pts/$N", 1, 0660) // O_WRONLY = 1
$2 = 1
(gdb) quit

Changing standard Input and Output to a different virtual Terminal.

Posted Nov 30, 2012 23:03 UTC (Fri) by jimparis (subscriber, #38647) [Link]

There are some details you still need to handle, like termios settings and the controlling terminal. See http://blog.nelhage.com/2011/01/reptyr-attach-a-running-p... for a program that can help (and links to some others).

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds