A invocação de reptyr
é suficiente para desanexar o terminal, mas tem que ser
sudo reptyr -T $PID
De man reptyr
:
-T
Use an alternate mode of attaching, "TTY-stealing".
In this mode, reptyr will not ptrace(2) the target process, but will attempt to discover he terminal emulator for that process' pty, and steal the master end of the pty.
This mode is more reliable and flexible in many circumstances (for instance, it can attach all processes on a tty, rather than just a single process).
However, as a downside, children of sshd(8) cannot be attached via -T unless reptyr is run as root. See ⟨https://blog.nelhage.com/2014/08/new-reptyr-feature-tty-stealing/⟩ for more information about tty-stealing.