On 6/22/19 12:43 PM, Antoine Jacoutot wrote: > On Sat, Jun 22, 2019 at 10:42:39AM -0400, Jacob Adams wrote: >> On 6/22/19 7:05 AM, Antoine Jacoutot wrote: >>> On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote: >>>> I've got a shell script I'd like to run as a system service. Due to the >>>> 16 character limitation on pgrep and the -x flag that rc.subr passes to >>>> check by default, I can't get check or stop to work correctly. The >>>> problem is that the process name looks like "/bin/sh >>>> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match >>>> when -x is used. >>>> >>>> My rc.d script currently looks like this: >>>> >>> Hi. >>> >>> That should not be an issue, that's why pexp is used for. >>> But without more context it's hard to know how to help you. >>> >>> I can match sh scripts without issue: >>> $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session" >>> 77289 >>> >>> Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"? >>> We don't run into the 16 chars limitation when using -xf >> >> Here's what I was seeing that led me to that conclusion: >> >> rukey$ ps aux | grep authmail >> root 51889 0.0 0.1 724 568 p0- Ip Fri12AM 0:00.01 >> /bin/sh /usr/local/bin/authmail >> jacob 25510 0.0 0.2 272 892 p0 S+p 10:36AM 0:00.01 grep >> authmail >> rukey$ pgrep -f /bin/sh /usr/local/bin/authmail >> 51889 >> rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail >> >> >> However, I didn't think to quote it. that seems to fix it: >> >> rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail" >> 51889 >> >> It appears that rc.subr uses quotes, but: >> >> rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail" >> 51889 >> rukey# rcctl check authmail >> authmail(failed) >> rukey# >> >> Any idea what could be going wrong here? > Dunno, run rcctl in debug mode.
rukey# ps ux | grep authmail root 93772 0.0 0.2 272 892 p0 S+p 2:10PM 0:00.01 grep authmail rukey# rcctl -d start authmail doing _rc_parse_conf doing _rc_quirks authmail_flags empty, using default >< doing _rc_parse_conf /var/run/rc.d/authmail doing _rc_quirks doing rc_check authmail doing rc_start doing _rc_wait start doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check doing rc_check Alarm clock /etc/rc.d/authmail: kill: 73440: No such process doing _rc_write_runfile (ok) rukey# rcctl -d check authmail doing _rc_parse_conf doing _rc_quirks authmail_flags empty, using default >< doing _rc_parse_conf /var/run/rc.d/authmail doing _rc_quirks authmail doing rc_check (failed) rukey# ps | grep authmail 17035 p0 Ip 0:00.01 /bin/sh /usr/local/bin/authmail 25162 p0 R+p 0:00.01 grep authmail rukey#

