From owner-freebsd-arch Sun Jun 17 14: 1:17 2001 Delivered-To: freebsd-arch@freebsd.org Received: from area51.v-wave.com (area51.v-wave.com [24.108.173.252]) by hub.freebsd.org (Postfix) with SMTP id B45C637B401 for ; Sun, 17 Jun 2001 14:00:51 -0700 (PDT) (envelope-from flatline@area51.v-wave.com) Received: (qmail 38198 invoked by uid 1001); 17 Jun 2001 21:00:50 -0000 Date: Sun, 17 Jun 2001 15:00:50 -0600 From: Chris Wasser To: arch@FreeBSD.org Subject: netbsd rc system diff Message-ID: <20010617150050.F582@skunkworks.arpa.mil> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Operating-System: FreeBSD 4.2-STABLE i386 X-Subliminal: On the count of 3, you will bark like a dog. 1.. 2.. 3.. Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I'm not sure how many people will agree with this, but here's a diff to rc.subr that applies the following premise: a) services started from init generally will be started with absolute path. For example: in /etc/rc.conf: sshd_enable="YES" sshd_program="/usr/sbin/sshd" sshd_flags="-p 22" A process report will show that indeed, sshd has been started with absolute path: # ps -ax -o 'pid,command' | grep sshd PID COMMAND 25063 /usr/sbin/sshd -p 22 38124 grep sshd b) some processes use setproctitle(3) to change how the process report will show up in a report, to overcome this problem, we sort the process report so that () and // are placed first in the report, reducing potential false positive matches: # ps -ax -o 'pid,command' | sort +1 4 (bufdaemon) 2 (pagedaemon) 0 (swapper) 5 (syncer) 3 (vmdaemon) 157 /sbin/dhclient dc0 1 /sbin/init -- 15041 /sbin/ipmon -Ds 30809 /usr/sbin/cron 16699 /usr/sbin/inetd -wW -l -c 100 -C 10 18072 /usr/sbin/named -u bind -g bind 60441 /usr/sbin/sshd -p 2222 22947 /usr/sbin/syslogd -ss PID COMMAND 24 adjkerntz -i 44231 ps -ax -o pid,command 17173 sshd: flatline (sshd) 34624 sshd: flatline (sshd) 34630 sshd: flatline (sshd) 44219 sshd: flatline@ttyp0 (sshd) ...etc Attached is a diff to rc.subr which applies the aforementioned implementation. Ofcourse this isn't a end-all-be-all solution, ideally a specialized tool would be used to differentiate which is an actual parent process and which are children/threads. - Chris --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rc.subr.diff" --- rc.subr Sun Jun 17 14:14:16 2001 +++ rc.subr.new Sun Jun 17 14:29:23 2001 @@ -116,12 +116,13 @@ return fi _procnamebn=${_procname##*/} - ps -p $_pid -o 'pid,command' | while read _npid _arg0 _argv; do + ps -p $_pid -o 'pid,command' | sort +1 | while read _npid _arg0 _argv; do if [ "$_npid" = "PID" ]; then continue fi if [ "$_arg0" = "$_procname" \ -o "$_arg0" = "$_procnamebn" \ + -o "$_arg0" = "/${_procnamebn}" \ -o "$_arg0" = "${_procnamebn}:" \ -o "$_arg0" = "(${_procnamebn})" ]; then echo $_npid @@ -143,12 +144,13 @@ fi _procnamebn=${_procname##*/} _pref= - ps -ax -o 'pid,command' | while read _npid _arg0 _argv; do + ps -ax -o 'pid,command' | sort +1 | while read _npid _arg0 _argv; do if [ "$_npid" = "PID" ]; then continue fi if [ "$_arg0" = "$_procname" \ -o "$_arg0" = "$_procnamebn" \ + -o "$_arg0" = "/${_procnamebn}" \ -o "$_arg0" = "${_procnamebn}:" \ -o "$_arg0" = "(${_procnamebn})" ]; then echo -n "$_pref$_npid" --envbJBWh7q8WU6mo-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message