I've got a really simple wrapper script to start a ruby program that monitors a network connection. The script's on router - hence we're using ash, not bash.
Since we're using monit to monitor the status, I need a PID file. The problem is, the process id set by the wrapper is one less than the ruby program.
Monit therefore spans hundreds of processes. How can I get the wrapper to start the ruby program and create the correct pidfile?
My wrapper looks like this:
#!/bin/sh /etc/rc.common
  start(){
    echo $$ > /var/run/ping.pid
    ruby /etc/scripts/ping.rb & > /dev/null 2>&1
  }
  stop(){
    kill `cat /var/run/ping.pid`
}