
Ispy: A python script for monitoring the output of other terminals and processes - d23
https://github.com/dellis23/ispy
======
mistaken
Why ptrace? Why not just take a peek from the stdout/stderr streams in
/proc/$pid/fd?

~~~
d23
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.

~~~
mistaken
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...](http://stackoverflow.com/questions/1323956/how-to-redirect-
output-of-an-already-running-process)) This would give a nice performance
boost if you could implement this in your code.

------
rickycook
also interesting is reTTY
[http://pasky.or.cz//dev/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

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

------
nathancahill
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](http://pipeup.io/tailnx#about)

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

~~~
teddyh
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.

------
tedmiston
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?

~~~
d23
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.

------
bdg
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.

------
eugenekolo2
Can this work remotely? For remote screen showing.

~~~
gouggoug
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.

~~~
d23
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.

