Hacker News new | past | comments | ask | show | jobs | submit login
Ispy: A python script for monitoring the output of other terminals and processes (github.com)
97 points by d23 on Dec 21, 2015 | hide | past | web | favorite | 15 comments

Why ptrace? Why not just take a peek from the stdout/stderr streams in /proc/$pid/fd?

I've tried this approach and haven't been successful. Mostly I just wanted to try ptrace. I got as far as trying to read the file descriptors and getting nothing back.

I'd love to hear how to do it this way though, since it would probably be a lot more robust and performant. My email is in `setup.py` in the repo if you want to reach out.

Fair enough. Simply reading from the file descriptor won't work since some of the output will be redirected to the original process depending on who reads the next character first. The solution is to attach to the process using ptrace and then reditrect the stdout using dup. There is an example on how to do this with gdb on stackoverflow (http://stackoverflow.com/questions/1323956/how-to-redirect-o...) This would give a nice performance boost if you could implement this in your code.

also interesting is reTTY http://pasky.or.cz//dev/retty/

it lets you "steal" the tty of a running process. benefits of this include starting tmux, then yanking an already running process into it

Is there a comparison of reTTY with reptyr (https://github.com/nelhage/reptyr)? reptyr claims to work with less while reTTY does not.

Neat. I wrote something similar using websockets for piping stdout/stderr to the web[0]. This is much lower level, I'll be reading the code to see if I can improve performance in PipeUp.

[0] http://pipeup.io/tailnx#about

I'm disappointed it's not is.py .

You can’t have a library named using any Python reserved keyword. I mean, how would you import it?

  import is
would be a syntax error, since “is” is the Python identity comparison operator.

This is interesting, but I'm not sure I understand the use case.

Is Ispy intended as an alternative to, for example, running tail -f on a log file? Or for interactive programs where I might not have a log file?

Honestly, in the past I've wanted something like this when a co-worker was running a process that was outputting progress, and I didn't want to keep bugging them to see how far along it was. You could use it to check on something like that.

The evil use case is just to watch what someone else is doing.

On BSD there's a fun little command called `watch` which lets me watch everything on any given TTY or even interact with it.

Great when working on a system with a jr. team member who isn't familiar as you can both have hands-on a system.

Can this work remotely? For remote screen showing.

You can provide multiple viewers read-only access to session using a combination of ttyrec by the recorder, and ttyplay in streaming mode for incoming tcp connections. Perhaps using socat, inetd, systemd, etc: http://0xcc.net/ttyrec/index.html.en

I doubt ipsy support remote screen sharing because it's a toy project that the author made to learn more about ptrace.

Terminal multiplexers like screen or tmux might be more adapted for terminal sharing.

It should work, but it'll slow down any process you're tracing. As you mentioned, screen works great for stuff that you have the foresight ahead of time to run in a screen session, such as a remote demo.

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