nelhage / reptyr

Reparent a running program to a new terminal
MIT License
5.77k stars 216 forks source link

Yama: check ahead of trying ptrace attach would be more desirable #59

Closed jnpkrn closed 9 years ago

jnpkrn commented 9 years ago

Since (a bit controversial) introduction of YAMA with default ptrace_scope set to 1 in Fedora 22, I had an unpleasant experience with reptyr attaching to vim process. Reptyr failed providing a good enough diagnostics about the problem, however when I fg'd the vim at the original terminal, I couldn't see the expected screen nor C^L was working (in retrospect, I've found out that blindly typing <Esc> followed with :redraw<Enter> would have actually helped me in that case).

Hence I would like to ask if either check_ptrace_scope detect-only-equivalent, or at least a dumb forked-child-tries-to-attach-to-parent test (or a mix of these two) could be carried out before actually trying the effective attach to prevent such distorted experience. Or would you consider this a vim's fault in not anticipating such scenario and in turn not redrawing when desired?

nelhage commented 9 years ago

Hm, that's frustrating. It seems like a bug that vim doesn't respect ^L in that case, but it's also not unreasonable to want repytr to fail faster here. I think it wouldn't be hard to do a quick “Can I attach?” check before the initial SIGSTOP, but I'll take a look.

jnpkrn commented 9 years ago

Thanks! Can help with testing and perhaps even with some prototypes, just let me know what you think would be optimal.

nelhage commented 9 years ago

I just pushed a quick test to the preflight-check branch, that works in my testing. Want to take a look?

jnpkrn commented 9 years ago

Works well for me, thanks!