You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Hyde <bh...@gensym.com> on 1998/06/04 23:51:38 UTC

[PATCH] avoid ps -p on SunOS

This works on all my machines and since uname is
used in GuessOS it seems dependable.  - ben

> cvs diff -u apachectl
Index: apachectl
===================================================================
RCS file: /cvs/apache-1.3/src/support/apachectl,v
retrieving revision 1.6
diff -u -r1.6 apachectl
--- apachectl	1998/03/31 12:53:46	1.6
+++ apachectl	1998/06/04 21:41:46
@@ -44,12 +44,16 @@
     ARGS="help"
 fi
 
+OSKIND=`uname`
+PSFLAG='-p'
+if [ "x$OSKIND" = "xSunOS" ] ; then PSFLAG=' ' ;fi
+
 for ARG in $@ $ARGS
 do
     # check for pidfile
     if [ -f $PIDFILE ] ; then
 	PID=`cat $PIDFILE`
-	PS=`ps -p $PID 2>/dev/null | tail -1 | grep $PID`
+	PS=`ps $PSFLAG $PID 2>/dev/null | tail -1 | grep $PID`
 	if [ "x$PS" = "x" ]; then
 	    STATUS="httpd (pid $PID?) not running"
 	    RUNNING=0

Re: [PATCH] avoid ps -p on SunOS

Posted by Marc Slemko <ma...@worldgate.com>.
On Thu, 4 Jun 1998, Ben Hyde wrote:

> 
> This works on all my machines and since uname is
> used in GuessOS it seems dependable.  - ben

The problem is that there is more than just SunOS that has this problem.

I knew this was a problem when I wrote it, but there isn't a nice solution
(there was some reason I didn't use kill -0, but I am trying to remember
the details...) and -p works on the systems I care about.  <g>

> 
> > cvs diff -u apachectl
> Index: apachectl
> ===================================================================
> RCS file: /cvs/apache-1.3/src/support/apachectl,v
> retrieving revision 1.6
> diff -u -r1.6 apachectl
> --- apachectl	1998/03/31 12:53:46	1.6
> +++ apachectl	1998/06/04 21:41:46
> @@ -44,12 +44,16 @@
>      ARGS="help"
>  fi
>  
> +OSKIND=`uname`
> +PSFLAG='-p'
> +if [ "x$OSKIND" = "xSunOS" ] ; then PSFLAG=' ' ;fi
> +
>  for ARG in $@ $ARGS
>  do
>      # check for pidfile
>      if [ -f $PIDFILE ] ; then
>  	PID=`cat $PIDFILE`
> -	PS=`ps -p $PID 2>/dev/null | tail -1 | grep $PID`
> +	PS=`ps $PSFLAG $PID 2>/dev/null | tail -1 | grep $PID`
>  	if [ "x$PS" = "x" ]; then
>  	    STATUS="httpd (pid $PID?) not running"
>  	    RUNNING=0
>