While trying to trace why several apps (all written in Perl) on my system always report 'crashed' status, I ultimately traced it to the WAIT_PIDFILE interval being too short. The apps follow the following pattern: 1. startup 2. basic checks 3. fork() to daemon 3.1. original exec returns to s-s-d 4. daemon does more complex checks 5. daemon writes pidfile. If #4 takes longer than the WAIT_PIDFILE interval, then it will do one of two things: 1. If --pidfile was NOT specified, s-s-d reports successful start, but later reports status as 'crashed'. 2. If --pidfile was specified, s-s-d fails hard, with: start-stop-daemon: did not create a valid pid in `$FOO'
Obviously the daemon should carry out complex checks AND writes the pidfile BEFORE forking. Any other situation is prone to racing. But this bug is invalid anyway - OpenRC-0.5 ditched WAIT_PIDFILE and now supports 3 ways of setting it - command line -w N, env var SSD_STARTWAIT=N or rc_start_wait set in a configuration file. The default is 0.