Have a look at reptyr, which does exactly that. The github page has all the information.
reptyr – A tool for “re-ptying” programs.
reptyr is a utility for taking an
existing running program and attaching
it to a new terminal. Started a
long-running process over ssh, 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.USAGE
reptyr PID
“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 ^C and ^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.)
Related Posts:
- Kill detached screen session [closed]
- Changing the resolution of a VNC session in linux
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- Terminal Multiplexer for Microsoft Windows – Installers for GNU Screen or tmux
- Can I nohup/screen an already-started process?
- How to reconnect to a disconnected ssh session
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- How to re-order windows, change the scroll shortcut, and modify the status bar contents in GNU Screen?
- Can I send some text to the STDIN of an active process running in a screen session?
- How do I deal with a filename that starts with the hyphen (-) character?
- Chmod 777 to a folder and all contents [duplicate]
- Bash: No such file or directory?
- Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
- Confused about stdin, stdout and stderr?
- What’s a .sh file?
- Amazon Linux: apt-get: command not found
- How to set the environmental variable LD_LIBRARY_PATH in linux
- What’s a .sh file?
- How can I symlink a file in Linux? [closed]
- How to fix ‘sudo: no tty present and no askpass program specified’ error?
- How do I grep recursively?
- How do I grep recursively?
- Why do you need to put #!/bin/bash at the beginning of a script file?
- How to get the url of the current svn repo?
- What does pss mean in /proc/pid/smaps
- apt-get error: Sub-process /usr/bin/dpkg returned an error code (1)
- How do I find all files containing specific text on Linux?
- How to unmount a busy device
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- How to unmount a busy device
- error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ — Missing /var/run/mysqld/mysqld.sock
- performing HTTP requests with cURL (using PROXY)
- Where can I find php.ini?
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ — Missing /var/run/mysqld/mysqld.sock
- No space left on device
- How do I grep recursively?
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- Amazon Linux: apt-get: command not found
- How to install grub after installing Windows 10
- Linux: ‘Username’ is not in the sudoers file. This incident will be reported
- how to find libstdc++.so.6: that contain GLIBCXX_3.4.19 for RHEL 6?
- How to extract C source code from .so file?
- Pass a password to ssh in pure bash
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- How to substitute shell variables in complex text files
- -bash: syntax error near unexpected token `newline’ for display command
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- SSH using python script
- Curl command for https ( SSL )
- How can I exclude directories from grep -R?
- How to exclude a directory in find . command
- “sed” command in bash
- How can I exclude directories from grep -R?
- gcc: error: unrecognized command line option
- How to exclude a directory in find . command
- How can I find all *.js file in directory recursively in Linux?
- mysql_config not found when installing mysqldb python interface
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- How to set proxy for wget?
- Shell command to tar directory excluding certain files/folders
- Argument list too long error for rm, cp, mv commands
- QEMU: /bin/sh: can’t access tty; job control turned off
- How to change permissions for a folder and its subfolders/files in one step
- Difference between using “chmod a+x” and “chmod 755”
- Explaining the ‘find -mtime’ command
- Meaning of exit status 1 returned by linux command
- Building HelloWorld C++ Program in Linux with ncurses
- How does “cat << EOF" work in bash?
- ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known
- Docker can’t connect to docker daemon
- Need a good hex editor for Linux
- Pseudo-terminal will not be allocated because stdin is not a terminal
- tar removing leading ‘/’ from member names
- X11 forwarding request failed on channel 0
- WSL – GEDIT Unable to init server: Could not connect: Connection refused
- Python subprocess.Popen “OSError: [Errno 12] Cannot allocate memory”
- Install tkinter for Python
- Directory Inode vs Regular File Inode
- Creating a new directory in C
- How to cat <
> a file containing code? - How to open some ports on Ubuntu?
- What is difference between arm64 and armhf?
- Extract file basename without path and extension in bash
- Opening a .tar.gz file with a single command
- Given two directory trees, how can I find out which files differ by content?
- How to change permissions for a folder and its subfolders/files in one step
- mv: cannot stat error : No such file or directory error
- How to make and apply SVN patch?
- Uncompress tar.gz file
- mysql_config not found when installing mysqldb python interface
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- Diff command along with Grep gives “Binary file (standard input) matches”
- can’t remove python pip
- What does it mean to mount a file system in linux?
- Pseudo-terminal will not be allocated because stdin is not a terminal