Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Reptyr: move an already-running process into screen (better than screenify) (nelhage.com)
55 points by kevinr on Jan 22, 2011 | hide | past | favorite | 8 comments


This seems useful. I would welcome some guidance on what's going wrong, here.

  met% ps -aef | grep python | grep time
  myusername 25476 25417  0 16:05 pts/9    00:00:00 python -c import time, sys; [sys.stdout.write(str(i)+"\n") or time.sleep(1) for i in range(1000)]
  met% sudo ~/src/reptyr/reptyr 25476
  [+] Allocated scratch page: 7f4477b3d000
  [+] Looking up fds for tty in child.
  [+] Resolved child tty: /dev/pts/9
  [+] Found an alias for the tty: 0
  [+] Found an alias for the tty: 1
  [+] Found an alias for the tty: 2
  Unable to attach to pid 25476: Permission denied
Same thing happens when I try to take control of an ssh session.

Ubuntu 10.04.1, built with

  met% git clone https://github.com/nelhage/reptyr.git
  met% cd reptyr/
  met% make


Hm. It currently has a bunch of known limitations, and the debug output probably isn't helpful to anyone other than me at the moment, but that test case works on my Maverick (Ubuntu 10.10) and Lucid (10.04) systems, so I'm not sure why it's failing for you. If you'd like me to take a look, the most helpful thing you could get me would be to install strace, and then run

  strace -o /tmp/reptyr.strace ~/src/reptyr/reptyr PID
and then send me the contents of /tmp/reptyr.strace

Thanks!


Another useful command, along the same lines, is disown. This is basically nohup, but for a process which is already running.


Thanks for writing this. I once had a Dwarf Fortress game that got lost to a hung ssh session; I could have used something like this.

Does it work with x apps? Because it would be great to be able to start my IDE over ssh on the laptop knowing I could switch to the desktop with losing what I had open.


For moving or persisting X applications you would need something like http://en.wikipedia.org/wiki/Xmove


how much is linux specific in this?


Most of this. It uses ptrace() to connect to the target and then make the target make specific system calls and ioctl()s on various fd's. I bet it could be ported to other unixes (assuming they have equivalent tty syscalls and ioctl's), but you'd have to change a lot of the details.

If someone wants to try a port to, say, a BSD that abstracts the syscalls and ioctls into a platform-specific way, I'd be happy to take a look.


this guy seems to love himself...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: