nelhage / reptyr

Reparent a running program to a new terminal
MIT License
5.78k stars 216 forks source link

Old terminal not freed #6

Closed ssadler closed 13 years ago

ssadler commented 13 years ago

When grabbing a process, the old terminal is not freed. Ctrl-\ will free it but kill the original process. Ideally you'd want the terminal to be freed and a message saying it was grabbed by another terminal.

nelhage commented 13 years ago

Unfortunately, there is no good way to free the old terminal in general. You can background the program and then do 'bg; disown' yourself, or just close the old terminal (i.e. close the xterm or kill the screen window or whatever) -- reptyr causes the attached program to ignore SIGHUP so that it shouldn't be killed.

ssadler commented 13 years ago

Out of interest, is it not possible to write commands to background and detatch the process to the old terminal?

nelhage commented 13 years ago

If I was willing to assume that the shell understands the "bg" and "detach" commands, I could probably inject those into the terminal and feed them to the shell at an appropriate time, and it wouldn't be unreasonable to add an option to do that. It wouldn't be trivial, though, since I'd need to find the other end of the pty in order to inject commands, and I don't know of a straightforward way to do that.

ssadler commented 13 years ago

Ah okay. Thanks