Bug 217297

Summary: [www/fcgiwrap] Stale fcgiwrap processes left even after service is stopped
Product: Ports & Packages Reporter: spry
Component: Individual Port(s)Assignee: Adam Weinberger <adamw>
Status: Closed FIXED    
Severity: Affects Only Me CC: lstewart
Priority: --- Flags: bugzilla: maintainer-feedback? (adamw)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Use a custom stop command that kills the pgrp none

Description spry 2017-02-22 14:14:05 UTC
Hi

Seems there is a problem w/ stale processes not being killed

USER   PID %CPU %MEM   VSZ  RSS TT  STAT STARTED    TIME COMMAND
www  18674  0.0  0.0 14492 2036  -  SsJ   8:49AM 0:00.00 daemon: /usr/local/sbin/fcgiwrap[18675] (daemon)
www  18675  0.0  0.0 14472 2012  -  SJ    8:49AM 0:00.00 - /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  18677  0.0  0.0 14472 2016  -  SJ    8:49AM 0:00.00 |-- /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  18678  0.0  0.0 14472 2016  -  SJ    8:49AM 0:00.00 |-- /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  18679  0.0  0.0 14472 2016  -  SJ    8:49AM 0:00.00 |-- /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  18680  0.0  0.0 14472 2016  -  SJ    8:49AM 0:00.00 `-- /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4

root@:~# /usr/local/etc/rc.d/fcgiwrap stop
===> fcgiwrap profile: xxxx
Stopping fcgiwrap.

...

www  61512  0.0  0.0 14472 2060  -  IJ   Thu09AM 0:00.00 /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  61513  0.0  0.0 14472 2016  -  IJ   Thu09AM 0:00.00 /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  61514  0.0  0.0 14472 2016  -  IJ   Thu09AM 0:00.00 /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
www  61515  0.0  0.0 14472 2016  -  IJ   Thu09AM 0:00.00 /usr/local/sbin/fcgiwrap -s unix:/var/run/fcgiwrap/fcgiwrap.alerts.socket -c 4
...


Should there be something like ?

--- fcgiwrap    2017-01-12 23:12:54.000000000 -0500
+++ /usr/local/etc/rc.d/fcgiwrap        2017-02-22 09:06:05.940283000 -0500
@@ -92,6 +92,7 @@
        case ${fcgiwrap_socket} in
                unix*)
                test -S ${fcgiwrap_socket#unix:} && rm -f ${fcgiwrap_socket#unix:}
+               killall fcgiwrap
                ;;
        esac
        rm -f $pidfile
Comment 1 Adam Weinberger freebsd_committer freebsd_triage 2017-02-22 15:10:29 UTC
I can confirm this behaviour when fcgiwrap_flags="-c 4". The main process gets killed but the extras don't.

I'm hesitant to use `killall fcgiwrap` because it prevents killing just one profile. I'm not sure how else to do it, though.
Comment 2 spry 2017-02-22 15:14:49 UTC
Yeah you're right, I only have 1 profile at the moment for this tho, multiple profiles need to also be considered. Arrr...
Comment 3 Lawrence Stewart freebsd_committer freebsd_triage 2017-05-22 04:07:51 UTC
Created attachment 182791 [details]
Use a custom stop command that kills the pgrp

Stopping fcgiwrap is very flaky for me on 12-CURRENT out of the box, and almost always gets stuck "Waiting for PIDS" until rc.subr gives up.

The attached patch against the fcgiwrap rc.d script is working well for me and should be profile friendly (though has not been tested with multiple profiles).
Comment 4 spry 2017-05-26 16:22:56 UTC
(In reply to Lawrence Stewart from comment #3)

Thanks. Works for me! Not tested w/ > 1 profiles tho.
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-05-26 16:55:30 UTC
A commit references this bug:

Author: adamw
Date: Fri May 26 16:54:40 UTC 2017
New revision: 441799
URL: https://svnweb.freebsd.org/changeset/ports/441799

Log:
  Fix stale processes not being terminated by the rc(8) script.

  Previously, when fcgiwrap_flags="-c [n]" with n > 1, only the controlling
  process was terminated, with the children running. This patch fixes this
  behaviour, terminating the children.

  PR:		217297
  Submitted by:	lstewart
  Reported by:	spry anarchy in the ph
  MFH:		2017Q2

Changes:
  head/www/fcgiwrap/Makefile
  head/www/fcgiwrap/files/fcgiwrap.in
Comment 6 Adam Weinberger freebsd_committer freebsd_triage 2017-05-26 16:56:34 UTC
Sorry about the delay in committing this! Thanks for the patch, Lawrence. It's committed now. I'm leaving the PR open pending a merge to quarterly.
Comment 7 commit-hook freebsd_committer freebsd_triage 2017-05-27 16:06:42 UTC
A commit references this bug:

Author: adamw
Date: Sat May 27 16:05:47 UTC 2017
New revision: 441851
URL: https://svnweb.freebsd.org/changeset/ports/441851

Log:
  MFH: r438923 r441799

  r438923:
  Release these ports to the collective.

  r441799:
  Fix stale processes not being terminated by the rc(8) script.

  Previously, when fcgiwrap_flags="-c [n]" with n > 1, only the controlling
  process was terminated, with the children running. This patch fixes this
  behaviour, terminating the children.

  PR:		217297
  Submitted by:	lstewart
  Reported by:	spry anarchy in the ph

  Approved by:	ports-secteam (miwi)

Changes:
_U  branches/2017Q2/
  branches/2017Q2/sysutils/vimpager/Makefile
  branches/2017Q2/www/fcgi/Makefile
  branches/2017Q2/www/fcgiwrap/Makefile
  branches/2017Q2/www/fcgiwrap/files/fcgiwrap.in
Comment 8 Adam Weinberger freebsd_committer freebsd_triage 2017-05-27 16:07:43 UTC
MFH is done. Thanks again for the patch, Lawrence.
Comment 9 Lawrence Stewart freebsd_committer freebsd_triage 2017-05-28 02:45:56 UTC
Thanks for taking care of it Adam.