J'ai un script init /etc/init.d/myservicepour initialiser un service comme celui-ci:
...
start() {
...
daemon /usr/sbin/myservice
...
}
stop() {
...
pgrep myservice
pidof myservice
ps -ef | grep myservice
...
}
Et quand j'essaie d'arrêter le service, voici la sortie:
10000 10001
10000
root 10000 1 0 09:52 ? 00:00:02 /usr/sbin/myservice
root 9791 9788 0 10:06 pts/1 00:00:00 /bin/sh /sbin/service myservice stop
root 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 myservice
Est-ce attendu? Pourquoi pidofne renvoie que le PID correct du service que je veux arrêter et pgreprenvoie le PID du service et le PID du script init? Puis-je compter sur cela pidofqui ignorera toujours le PID du script init?
pidofne revient pas10001, parce que le programme estsh, non?