usrme / wishlistlite

The lesser SSH directory ✨
MIT License
3 stars 0 forks source link

Could a visualization be done for how the connections work? #19

Closed usrme closed 1 year ago

usrme commented 1 year ago

With the somewhat convoluted logic of starting the main program (i.e. Wishlist Lite), which starts a goroutine for the parent SSH connection and once that's done the main program is replaced with a child SSH connection to the control socket from the parent SSH connection, I'm wondering whether this seeming flow can somehow be visualized by observing system resources.

usrme commented 1 year ago

Here's how to roughly see how everything looks like:

I've removed some of the parent processes for brevity, but here are some static views:

systemd(1)───...───wishlistlite(85716)─┬─{wishlistlite}(85717)
                                       ├─{wishlistlite}(85718)
                                       ├─{wishlistlite}(85719)
                                       ├─{wishlistlite}(85720)
                                       ├─{wishlistlite}(85721)
                                       ├─{wishlistlite}(85722)
                                       ├─{wishlistlite}(85723)
                                       ├─{wishlistlite}(85724)
                                       └─{wishlistlite}(85725)
systemd(1)───...───wishlistlite(85716)─┬─ssh(85853)───ssh(85854)
                                       ├─{wishlistlite}(85717)
                                       ├─{wishlistlite}(85718)
                                       ├─{wishlistlite}(85719)
                                       ├─{wishlistlite}(85720)
                                       ├─{wishlistlite}(85721)
                                       ├─{wishlistlite}(85722)
                                       ├─{wishlistlite}(85723)
                                       ├─{wishlistlite}(85724)
                                       ├─{wishlistlite}(85725)
                                       ├─{wishlistlite}(85855)
                                       ├─{wishlistlite}(85856)
                                       ├─{wishlistlite}(85857)
                                       └─{wishlistlite}(85858)
systemd(1)───...───ssh(85716)───ssh(85853)

Note how the original process ID of Wishlist Lite (85716) is now that of the SSH process'. This is happening because of the call to syscall.Exec here, which in turn invokes the 'execve(2) system call', which:

causes the program that is currently being run by the calling process to be replaced with a new program, with newly initialized stack, heap, and (initialized and uninitialized) data segments.

usrme commented 1 year ago

I'm thinking that I'll just add this to the README and be done with it as I don't think there's a big point in trying to postpone this in the hopes of finding a nice automatic visualization.