

Reptyr – Reparent a running program to a new terminal - pmoriarty
https://github.com/nelhage/reptyr

======
justincormack
There was some discussion on the NetBSD list today as to how you might do this
properly, ie with OS support not some hacks [1]. Although it is not clear it
is worth bothering, as you just use screen first...

[1]
[http://blog.gmane.org/gmane.os.netbsd.devel.kernel](http://blog.gmane.org/gmane.os.netbsd.devel.kernel)

~~~
pmoriarty
This is useful for those cases where you didn't start screen first, such as
when you either forgot or didn't think you'd need it but it turned out you
did.

~~~
pronoiac
This may be a dumb question, but wouldn't this work?

* press ctrl-z to put the program in the background

* start screen

* run fg within screen

~~~
caipre
screen (and tmux) start a new instance of the shell, which would have no
knowledge of the backgrounded process. You'd just see the message "fg: no
current job"

~~~
emmelaich
And even if you could(1), the background process typically has the terminal
open - and screen uses a separate pseudo terminal aka pty -- As suggested by
the name - rePTYr

(1) ^Z sends SIGSTOP; to continue you can signal SIGCONT. But then what?!

------
sciurus
There is some previous discussion at
[https://news.ycombinator.com/item?id=2129726](https://news.ycombinator.com/item?id=2129726)
and
[https://news.ycombinator.com/item?id=2571936](https://news.ycombinator.com/item?id=2571936)

------
bob917
I tried this several times and it rarely works.

