reptyr: Doesn't work for processes which have spawned subprocesses
See:
# reptyr $(pgrep pkgmk)
[-] Process 4646 (pkgmk) shares 4604's process group. Unable to attach.
(This most commonly means that 4604 has a suprocesses).
Unable to attach to pid 4604: Invalid argument
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 30 (6 by maintainers)
reptyr master now includes a
-T
option, which uses an entirely different attachment strategy that, among other advantages, will attach the entire target terminal, including all processes. I still consider it experimental, but I’d appreciate testing and bug reports.One known limitation, unfortunately, because of how it works and an interaction with how
setuid
works on Linux, is that it won’t normally work on sessions that are spawned out of anssh
session unless the attachingreptyr
is run as root.You can
reptyr -T
the same process twice, the second time you just have to give the PID of thereptyr
process that you used the first time.Your terminal ends up in a weird state where you can type in commands but the process is running “at the same time” in the background, but since it is not a direct child of the shell, you can’t do
fg
orbg
to get it back under your control.Still, it’s useful if you need to move a long-running build process around into a different terminal just to keep it alive, for whatever reason.
@Sandoras you’re new to Linux but you’re running reptyr… You really have chosen to dive in at the deep end 😃
Some minimal steps to get a runnable version of the github tip if you don’t care about Bash completion and do not have root/sudo:
HTH
No updates? This is showstopper for pretty much any shell process that does something… Being able to use reptyr would be great to be able to reattach to long running shell scripts remotely/safely… (once you figure out they are taking too long)…
Did you mean version 0.5? It doesn’t look to me like it’s reached 5.0.
As far as I’m aware, the two versions should happily co-exist if that’s what you’re asking. You might want to uninstall the apt-get-provided version to avoid confusion though.
With regards to what directory to put it in, Linux isn’t particularly picky about where you put things. For example, you could install it to ~/reptyr and then run it as
~/reptyr/bin/reptyr
. If you want to be able to run it by just typingreptyr
you’ll want to look into modifying yourPATH
variable and your ~/.bashrc or equivalent. Some searching online should turn up plenty of advice for doing this.reptyr -T worked fine for me with a stuck old dpkg process that spawned a whiptail subshell for configuration options from another ssh session.
Great work and Thanks!
I’m running as root using sudo -i, but get unable to attach to pid 3822: Permission denied
Yeah, I’d really love to have this feature, but I’ve given it a bunch of thought and experimentation, and don’t know of a robust way to do it with the operations Linux gives you. I came up with a completely different approach involving stealing the pty, but unfortunately it won’t work for things started directly from an ssh session, which is much of the utility of reptyr 😕
If that’d be useful, I’d consider doing a prototype, but I just don’t know how to do this in general.