2

I'm looking at some init.d scripts, and a number of them use this what is essentially this command in their "stop)" target:

kill $(pidof ${DAEMON_NAME})

The pidof ${DAEMON_NAME} is actually a script function that checks the status code and calls exit if necessary, nonetheless, How is the above any different than this:

killall ${DAEMON_NAME}

A lot of init.d script simplification would be had if they are.

EDIT: I should add these "processes" aren't daemons and don't actually record their PID in the FS anywhere ...

Jamie
  • 1,274
  • 7
  • 22
  • 39
  • U&L is your friend: https://unix.stackexchange.com/search?q=kill+killall displays among other questions: [What is the difference between kill , pkill and killall](https://unix.stackexchange.com/questions/252349/what-is-the-difference-between-kill-pkill-and-killall). Hope that helps. – Paul Nov 23 '17 at 17:53
  • @Paul U&L? I read through the post ... it sort of confirms my suspicions. Thanks. – Jamie Nov 23 '17 at 17:56
  • I think killall is some sort of Kill-9 and not to send a SIGHUP – Max Muster Nov 23 '17 at 23:50
  • @eichertc No it isn't. It sends SIGHUP to processes that match the name. – Jamie Nov 28 '17 at 14:50

1 Answers1

0

Yes, they are functional identic.

pidof is a shell function.

Note that killall came after kill and was not available in all Linux/Unix variants.

So the kill/pidof was the more generic appoach if you had to write init-scrips.

Nils
  • 7,657
  • 3
  • 31
  • 71