EN - Re-parenting processes to a new terminal
This article might help you to manage your processes. You can train using the code given in this article.
Prerequisites
ubuntu
echo 0 > /proc/sys/kernel/yama/ptrace_scope
Install
apt
apt-get install reptyr
source
git clone https://github.com/nelhage/reptyr.git
cd reptyr
make all
cp reptyr /usr/loca/bin/reptyr
cd -
rm -rf reptyr
Usage
- Start a long-running process, e.g. htop
- Background the process with CTRL-Z
- Resume the process in the background: bg
- Display your running background jobs with jobs -l, this should look like this:
[1]+ 11216 Stopped (signal) htop
(The -l in jobs -l makes sure you’ll get the PID)
- Disown the jobs from the current parent with disown top. After that, jobs will not show the job any more, but ps -a will.
- Start your terminal multiplexer of choice, e.g.
tmux
- Reattach to the backgrounded process:
reptyr 11216
- Detach your terminal multiplexer (e.g. CTRL-A D) and close ssh
- Reconnect ssh, attach to your multiplexer (e.g. tmux attach), rejoice!
Example: