I rewrote pidof Linux terminal utility, please roast my code

139 points iyicanme

After needing to lookup PID of a process in a project, I figured rewriting the pidof would be better than calling the program. Boy, I was wrong. I mean, the end result is better, but it turned out to be a 2 week detour. Worst part was needing to read the procps code base, which turned out to be complete illegible in some sections. I'd definitely like to continue rewriting procps as the current implementation carries baggage from the past.

Anyway, I took this opportunity to learn clap and try to implement pidof 1-1 as a binary in addition to make it available as a library as originally intended. I would like some reviews to improve the code. Thanks!

Repository: https://gitlab.com/iyicanme/pidof-rs