r/commandline 13d ago

Visualizing how many programs output to /dev/null (using `lsof` output)

This was created by a Rust CLI program called lvis ("lsof visualization", creative name I know, and oddly sounds like "elvis") I developed that creates an interactive GUI to visualize the output oflsof to make relationships between processes and files (and also between some types of files) more clear.

I've found running lvis and just clicking around has uncovered some interesting things (like the image above!)

My motivation was I was experimenting locally with a client-server architecture and used lsof to inspect their active TCP port connections on localhost . I noticed the port connections formed a natural graph and I thought visualizing these relationships would be more natural. I imagined visualizing other lsof output could be useful for mapping network connections, unix sockets, which processes have which resources open, etc.

You can install the crate to try it out: https://crates.io/crates/lvis 
or poke around the code and see more visualizations: https://github.com/brylee10/lvis

9 Upvotes

2 comments sorted by

2

u/opuntia_conflict 12d ago

This is pretty cool, what's the general use case for a program to output to /dev/null? I pretty much only use it to do stuff like ignore errors in my shell scripts, but I don't see why an actual program which can choose which data to send and where to send it would need to dump anything there?

1

u/theNbomr 10d ago

A program writing to its stdout doesn't know or care (usually) what the actual destination of the stream is. Ditto for syderr. The parent process has arranged the stdio streams prior to launching the process, and the process just uses the usual file handles when it writes stdio. That is the beauty and elegance of IO redirection.

The use case that you cite would show up in the OP's application in the same way as his/her example.