rc script problem

Hi, I'm writing an rc script for a hand-made daemon. Got a problem with the pid file:
Code:
# /usr/local/etc/rc.d/perl_fcgi start
Starting perl_fcgi.

# ps axu|grep perl
nobody  57821  0.0  0.1 16796  4712  ??  SsJ  10:33AM   0:00.00 perl-fcgi-pm (perl5.10.1)
nobody  57822  0.0  0.1 16796  4716  ??  SJ   10:33AM   0:00.00 perl-fcgi (perl5.10.1)
nobody  57823  0.0  0.1 16796  4716  ??  SJ   10:33AM   0:00.00 perl-fcgi (perl5.10.1)
nobody  57824  0.0  0.1 16796  4716  ??  SJ   10:33AM   0:00.00 perl-fcgi (perl5.10.1)

# /usr/local/etc/rc.d/perl_fcgi stop
perl_fcgi not running? (check /var/run/perl_fcgi.pid).

# cat /var/run/perl_fcgi.pid
57821

# ps axu|grep `cat /var/run/perl_fcgi.pid`
nobody  57821  0.0  0.1 16796  4712  ??  IsJ  10:33AM   0:00.00 perl-fcgi-pm (perl5.10.1)
Why rc script see /var/run/perl_fcgi.pid but saying its not running? (((

Contents of /usr/local/etc/rc.d/perl_fcgi itself:
Code:
#!/bin/sh
#

# PROVIDE: perl_fcgi
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

load_rc_config perl_fcgi

name=perl_fcgi
rcvar=`set_rcvar`

command=/store/scripts/perl_fcgi.pl
pidfile=/var/run/${name}.pid

# default to disable
perl_fcgi_enable=${perl_fcgi_enable:-"NO"}

run_rc_command "$1"
What's the problem, why does it not see the pidfile or process?
 
It shouldn't be able to write to the pid file, the nobody user can't write in /var/run/. Try creating a /var/run/fcgi/ directory, set the owner to nobody and store the pid in there.
 
The script writing pidfile good and correct (see code in 1st post). Then - script makes setuid to nobody. If i remove /var/run/perl_fcgi.pid and then start server - it creates pidfile with valid pid inside..
So problem is not around pidfile creating


UPD: Problem solved. This was a problem with process naming. I have name variable in rc script which look like name=perl_fcgi, while started process named other manner(perl-fcgi-pm).
rc.subr is checking against pidfile AND process name, so i had to add
Code:
procname=perl-fcgi-pm
to rc script
 
Back
Top