Understanding how killall works using strace
jvns.ca
jvns.ca
I almost think this is one of those "rights of passage" -- that everybody must do this at least once. You'll learn it the hard way but then you'll never forget...
Kinda like many years ago when I was (new to Cisco gear and) making changes to a firewall ruleset -- remotely -- and decided to take a shortcut because I was supposed to go meet friends and so I was in a hurry.
Actually I did not learned the hard way. But I was about to..
Serial murderers shouldn't commit suicide. (killall should
avoid killing itself.)1: http://docs.oracle.com/cd/E19253-01/816-5166/killall-1m/inde...
Also, terminating an employee.
Why not to look into the source?
I used strace for different scenarios and always it saved the day. But this would not be my play for learning about killall.
Reading code has its place and tracing code has its place. I have difficulty understanding nontrivial codebases without some amount of tracing. In this case you chose to present the source for a FreeBSD/OS X version of killall when OP is running Linux.
http://sourceforge.net/p/psmisc/code/ci/master/tree/src/kill...
Julia Evans finished Hacker School, so I wonder if she continues with her Rust based operating system?
https://github.com/jvns/puddle
featured on HN 3 days ago: https://news.ycombinator.com/item?id=6935763
It's one of the things I miss on OS X. dtruss isn't as powerful, and dtrace seems like it might be more powerful but I have no idea how to use it.
http://en.wikipedia.org/wiki/Ltrace
> ltrace is a debugging utility in Linux, used to display the calls a userland application makes to shared libraries.
This is useful because strace can completely ignore the information you really want. OTOH, ltrace doesn't provide information that's as pretty as what strace shows, because ltrace doesn't know as much about the functions it's showing you. This means arguments passed as pointers will be shown as pointer values, functions will occasionally be shown as taking the wrong number of arguments, and enum values will be shown as ints.
ltrace also can't show function calls to functions in statically-linked libraries, because it hooks into the dynamic loading mechanism.