I have a init script in /etc/init.d/myservice for initialize a service like this:...start() {  ...  daemon /usr/sbin/myservice  ...}stop() {  ...  pgrep myservice  pidof myservice  ps -ef | grep myservice  ...}And when I try to stop the service, this is the output:10000 1000110000root      10000     1  0 09:52 ?        00:00:02 /usr/sbin/myserviceroot      9791   9788  0 10:06 pts/1    00:00:00 /bin/sh /sbin/service myservice stoproot      10001  9791  1 10:06 pts/1    00:00:00 /bin/sh /etc/init.d/myservice stop root      9805   9796  0 10:06 pts/1    00:00:00 grep myserviceIs this expected? Why pidof is returning only the correct PID of the service that I want to stop and pgrep is returning the service PID and the PID of the init script? Can I rely on that pidof will always ignore the PID from the init script? 
Why pidof and pgrep are behaving differently?
grep;process;init script;pidof
pidof = find the process ID of a running programPidof finds the process id's (pids) of the named programs.  It  prints   those  id's  on  the  standard output. This program is on some systems   used in run-level change scripts, especially when  the  system  has  a   System-V  like rc structure.sysadmin@codewarden:~$ pidof apache25098 5095 5094 5092pgrep = look  up or signal processes based on name and other attributes,         pgrep looks through the currently running processes and lists the       process IDs which matches the selection criteria. sysadmin@codewarden:~$ pgrep apache25092509450955098pgrep, (p) = process, grep = grep prints the matching lines Want to know more about pgrep & pidof ?Just run in terminal as# man pidof# man pgrep