|« Top 10 Reasons Why Firefox is still Better Than Chrome for Web Development||How to enable Keyboard Layout on OpenSuSE 11.4 and 12.x (Updated) »|
how to attach existing tty to screen
Have you ever started a long-running process over ssh without using screen command, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home. reptyr is a utility for taking an existing running program and attaching it to a new terminal. Download it from here
"reptyr PID" will grab the process with id PID and attach it to your current terminal. After attaching, the process will take input from and write output to the new terminal, including Ctrl+C and Ctrl+Z. (Unfortunately, if you background it, you will still have to run "bg" or "fg" in the old terminal. This is likely impossible to fix in a reasonable way without patching your shell.)
There's a shell script called "screenify" that's been going around the internet that uses gdb to (supposedly) accomplish the same thing. The difference is that reptyr works much, much, better. If you attach a "less" using screenify, it will still take input from the old terminal. If you attach an ncurses program using screenify, and resize the window, your program won't notice. If you attach a process with screenify, Ctrl+C in the new terminal won't work. reptyr fixes all of these problems, and is the only such tool I know of that does so.