You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Wilfredo Sanchez <ws...@apple.com> on 1998/06/25 06:21:47 UTC

[PATCH] ps in apachectl

apachectl uses ps -p, which fails for me on Rhapsody, Linux, and FreeBSD. It worked on AIX.

I believe most systems fall into the BSD "ps -aux" category or the SysV "ps -ef" variety.  AIX, being all funky and wierdo, does both.

The following patch attempts to correct this. apachectl is changed to us "ps -ef" and the top Makefile.tmpl is changed to see if "ps -aux" returns an error status, and if not, to changes apachectl  
to use "ps -aux" instead.  I'm assuming that one or the other will work and that in either case the PID is listed in column 2.

Index: Makefile.tmpl
===================================================================
RCS file: /CVSRoot/CoreOS/Services/apache/apache/Makefile.tmpl,v
retrieving revision 1.5
diff -u -b -d -r1.5 Makefile.tmpl
--- Makefile.tmpl       1998/06/25 04:17:23     1.5
+++ Makefile.tmpl       1998/06/25 04:17:36
@@ -298,8 +298,9 @@
        $(INSTALL_PROGRAM) $(SRC)/support/ab $(root)$(sbindir)/ab
        $(INSTALL_DATA) $(SRC)/support/ab.1 $(root)$(mandir)/man8/ab.1
        @echo "$(INSTALL_SCRIPT) $(SRC)/support/apachectl[*] $(root)$(sbindir)/apachectl"; \
+       if ps -aux >/dev/null 2>&1; then FIXPS="s/ps -ef/ps -aux/"; else FIXPS="s///"; fi; \
        sed -e 's;PIDFILE=.*;PIDFILE=$(runtimedir)/$(default_pidlog);' \
-               -e 's;HTTPD=.*;HTTPD=$(sbindir)/$(httpd);' \
+               -e 's;HTTPD=.*;HTTPD=$(sbindir)/$(httpd);' -e "$${FIXPS}" \
                < $(SRC)/support/apachectl > $(SRC)/.apaci.install.tmp && \
                $(INSTALL_SCRIPT) $(SRC)/.apaci.install.tmp $(root)$(sbindir)/apachectl
        $(INSTALL_DATA) $(SRC)/support/apachectl.1 $(root)$(mandir)/man8/apachectl.1
Index: src/support/apachectl
===================================================================
RCS file: /CVSRoot/CoreOS/Services/apache/apache/src/support/apachectl,v
retrieving revision 1.1.1.1
diff -u -b -d -r1.1.1.1 apachectl
--- apachectl   1998/06/16 15:36:02     1.1.1.1
+++ apachectl   1998/06/25 04:17:36
@@ -49,7 +49,7 @@
     # check for pidfile
     if [ -f $PIDFILE ] ; then
        PID=`cat $PIDFILE`
-       PS=`ps -p $PID 2>/dev/null | tail -1 | grep $PID`
+       PS=`ps -ef 2>/dev/null | awk '{print $2}' | grep $PID`
        if [ "x$PS" = "x" ]; then
            STATUS="httpd (pid $PID?) not running"
            RUNNING=0