reptyr(1)
π reptyr β reparent a running program to a new terminal π
okay bestie, welcome to the reptyr(1) manual page, General Commands Manual edition, and honestly? this little tool is a whole game changer. sit down, hydrate, let's go π«Ά
β¨ SYNOPSIS β¨
reptyr PID
reptyr -l|-L [COMMAND [ARGS]]
that's it. that's the whole summoning ritual πΈ
π¦ DESCRIPTION π¦
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 you have to leave and you don't want to interrupt it? no because same π. just start a screen, use reptyr to grab it, and then kill the ssh session and head on home. main character exit, periodt π
here's the tea on how it works: reptyr attaches to the target program using ptrace(2), redirects the relevant file descriptors, and changes the program's controlling terminal (see tty(4)). and it's that last detail that makes reptyr work so much better than alternatives like retty(1). like, not even a competition bestie β¨
after attaching a program, the program will look either backgrounded or suspended to the shell it was launched from (depends on the shell, they all have their own vibe). for maximal safety you can run:
bg; disown
in the old shell to remove the association with the program. but ngl, reptyr will attempt to make sure the target program keeps running even if you close the shell without doing that. so it's giving safety net, not giving guarantee π (do the bg; disown thing though, be a responsible icon).
π OPTIONS π
-Tβ uses an alternate mode of attaching, called "TTY-stealing". in this mode,reptyrwill notptrace(2)the target process β instead it attempts to discover the 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 ofsshd(8)cannot be attached via-Tunlessreptyris run as root. more info about tty-stealing lives at β¨https://blog.nelhage.com/2014/08/new-reptyr-feature-tty-stealing/β© π-l,-L [COMMAND [ARGS]]β instead of attaching to a new process, create a new pty pair, proxy the master end to the current terminal, and then print the name of the slave pty. you can pass that to e.g. gdb'sset inferior-ttyoption π
if an optional COMMAND and ARGS are passed in conjunction with -l, that command will be executed as a child of reptyr with the REPTYR_PTY environment variable set to the name of the slave pty. and if -L is used instead of -l, then fds 0-2 of the child will also be redirected to point to the slave, and the child will be run in a fresh session with the slave as its controlling terminal. fancy fr fr π
-sβ by default,reptyrwill move any file descriptors in the target that were connected to the target's controlling terminal so they point to the new terminal. the-soption makesreptyrunconditionally attach file descriptors0,1, and2in the target β even if the target has no controlling terminal, or those fds aren't connected to a terminal. no vibe check required, just full send π-vβ print the version ofreptyrand exit. short and sweet π-hβ print a usage message and exit π§-Vβ print verbose debug output while running. for when you need the play-by-play commentary ποΈ
π NOTES π
reptyr depends on the ptrace(2) system call to attach to the remote program. on Ubuntu Maverick and higher, this ability is disabled by default for security reasons π€. you can enable it temporarily by doing:
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
as root, or permanently by editing the file /etc/sysctl.d/10-ptrace.conf, which also contains more information about this setting. so like, permission slip required, bestie π
π BUGS π
listen. it's not perfect, no one is, and the manpage is being very honest with us:
- when attaching to some curses programs, they will not redraw the screen right away, and a
^Lor similar will be needed to force a redraw. rude of them honestly π - similarly, after attaching to certain programs, the old terminal will be left in an odd state, and a
clearor evenresetmay be required before the old terminal is usable again. it's giving haunted house energy π» - attaching to
rtorrent(and probably some other apps) doesn't work right (rtorrentstops accepting input). the problem is thatrtorrentis using epoll to poll stdin, and we don't update the internal reference that the epoll fd has to the old tty. mystery unsolved π - attaching to a process with children doesn't work right. this should be possible to fix β the author just needs to
ptraceeach child individually and do the same games to it. so like, technically doable, pending π - attaching a
less(1)process doesn't work if you have a.lessfilterfile, aslessleaves around a zombie child in this case. this could be worked around. zombie child!! spooky π§
bugs should be reported to the author (see below) or via the issue tracker on GitHub. don't suffer in silence, bestie, tell someone π£
π AUTHORS π
reptyr was written by Nelson Elhage <nelhage@nelhage.com>. icon behavior, no cap π
πΈ HOMEPAGE πΈ
β¨https://github.com/nelhage/reptyrβ© π¦
π SEE ALSO π
neercs(1), screen(1) β¨
and that's the whole page, bestie!! this manual page is from reptyr(1), dated 03 Feb 2011 β vintage but still absolutely slaying π
ππΈ
π¦ where this page comes from
- alpine 3.24: reptyr-doc 0.10.0-r0 Β· MIT
- arch rolling: reptyr 0.10.0-2 Β· BSD
- debian bookworm: reptyr 0.9.0-1+b1 Β· MIT
- debian trixie: reptyr 0.9.0-1+b1 Β· MIT
- epel 10: reptyr 0.10.0-6.el10_1 Β· MIT
- epel 9: reptyr 0.8.0-4.el9 Β· MIT
- fedora 43: reptyr 0.10.0-7.fc43 Β· MIT
- fedora 44: reptyr 0.10.0-8.fc44 Β· MIT
- nixos 26.05: reptyr 0.10.0
- nixpkgs unstable: reptyr 0.10.0
- opensuse-leap 16.0: reptyr 0.10.0-bp160.1.9 Β· MIT
- ubuntu jammy: reptyr 0.6.2-1.3 Β· MIT
- ubuntu noble: reptyr 0.9.0-1 Β· MIT
- ubuntu questing: reptyr 0.9.0-1
- ubuntu resolute: reptyr 0.9.0-1build1 Β· MIT
- ubuntu stonking: reptyr 0.10.0-0.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms