3

Having recently discovered reptyr, my first action was to do everything I could to break it. This included reptyring screen into a screen session as follows:

$ screen
My zshrc cats some stuff here.
$ reptyr $(pgrep screen)

I thought that this would fail either gracefully or badly, but the failure had some interesting side effects:

zsh: suspended  screen
                  %
Unable to attach to pid 24799: Operation not permitted
The kernel denied permission while attaching. If your uid matches
the target's, check the value of /proc/sys/kernel/yama/ptrace_scope.
For more information, see /etc/sysctl.d/10-ptrace.conf
$ jobs
zsh: command not found: jos
$ jobs
zsh: command not found: obs
$ jobs
[1]  + running screen
$ exit

My input is thoroughly garbled here, I'm not really sure what's going on with that process, and the exit command doesn't warn me about any jobs. What is the explanation for this?

drs
  • 5,363
  • 9
  • 40
  • 69
astex
  • 131
  • 4
  • This also creates an orphaned `SCREEN` process owned by root. – astex Sep 02 '14 at 15:08
  • 3
    +1 for actively trying to break things to see what happens. :) – peterph Sep 02 '14 at 15:27
  • For some reason there wasn't a "don't try this at home" tag. – astex Sep 02 '14 at 17:09
  • So if I try it at work, it's OK? ;-) – celtschk Sep 02 '14 at 17:47
  • Actually, it is a good question of how exactly it goes wrong. My gut feeling is that you created some race condition which caused some of the input getting "lost in the pty" or, more precisely, being delivered somewhere, where it wasn't *visibly* acted upon. But that's just hand-waving. – peterph Sep 02 '14 at 17:52
  • BTW, I notice that for me the first process which comes up with `pgrep screen` inside `screen` is `gnome-screensaver`, only then followed by the two `screen` processes. Anyway, does `reptyr` only try to redirect the first PID in the command line, or every PID? And what happens if you try to `reptyr` a process with no controlling terminal (as the "inner" screen process `SCREEN` is)? – celtschk Sep 02 '14 at 17:56
  • I actually did use the PID directly rather than `pgrep`. That was included here to make it easier to explain what I did. I'm pretty sure, from the man page, that `reptyr` can only take one argument, so it likely just ignores any additional processes. – astex Sep 02 '14 at 18:05

0 Answers0