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/03 05:12:20 UTC

sun4 and apachectl

the  ...  ps -p $PID ...
in apachectl doesn't work on the
sun4, so you can start, but not restart or
stop on that platform.  - ben hyde


Re: sun4 and apachectl

Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Jun 03, 1998 at 06:01:40PM -0500, Me at IO wrote:
> On Wed, Jun 03, 1998 at 03:49:52PM -0700, Dean Gaudet wrote:
> > bind's ndc uses "ps -p $pid"... which I think is why Marc implemented
> > apachectl that way.
> > 
> > Yet another option is "kill -0 $pid".
> 
> Here's a simple patch that uses it. The kill -0 concept seems to work
> under Red Hat Linux and AIX 4.2; it's untested on the rest (notably
> sun4).

And it turns out the fix was untested anywhere, because I ran
apachectl instead of ./apachectl. Thanks to Marc for noting the
problem: the if and else blocks were switched. The concept stays the
same, though. Here's a revised patch which seems to work.

*** apachectl.orig	Wed Jun  3 21:08:28 1998
--- apachectl	Wed Jun  3 20:51:16 1998
***************
*** 49,61 ****
      # check for pidfile
      if [ -f $PIDFILE ] ; then
  	PID=`cat $PIDFILE`
! 	PS=`ps -p $PID 2>/dev/null | tail -1 | grep $PID`
! 	if [ "x$PS" = "x" ]; then
! 	    STATUS="httpd (pid $PID?) not running"
! 	    RUNNING=0
! 	else
  	    STATUS="httpd (pid $PID) running"
  	    RUNNING=1
  	fi
      else
  	STATUS="httpd (no pid file) not running"
--- 49,60 ----
      # check for pidfile
      if [ -f $PIDFILE ] ; then
  	PID=`cat $PIDFILE`
! 	if kill -0 $PID 2> /dev/null; then
  	    STATUS="httpd (pid $PID) running"
  	    RUNNING=1
+ 	else
+ 	    STATUS="httpd (pid $PID?) not running"
+ 	    RUNNING=0
  	fi
      else
  	STATUS="httpd (no pid file) not running"

Users of the Apache webserver are hereby granted a non-exclusive,
irrevocable, world-wide, royalty-free, non-transferable license to
use, execute, prepare derivative works of, and distribute (internally
and externally, and including derivative works) the code accompanying
this license as part of, and integrated into the Apache webserver.
This code is provided "AS IS" WITHOUT WARRANTY OF ANY KIND EITHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE
RISK ARISING OUT OF THE USE OR PERFORMANCE OF THIS CODE REMAINS WITH
USERS OF THE APACHE WEBSERVER.  I represent and warrant that I am
legally entitled to grant the above license.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
"I am J. D. Falk, Sysadmin. I own a web-server and a LART." - Jeff Mercer

Re: sun4 and apachectl

Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Jun 03, 1998 at 03:49:52PM -0700, Dean Gaudet wrote:
> bind's ndc uses "ps -p $pid"... which I think is why Marc implemented
> apachectl that way.
> 
> Yet another option is "kill -0 $pid".

Here's a simple patch that uses it. The kill -0 concept seems to work
under Red Hat Linux and AIX 4.2; it's untested on the rest (notably
sun4).

*** apachectl.orig	Wed Jun  3 18:52:09 1998
--- apachectl	Wed Jun  3 18:54:55 1998
***************
*** 49,56 ****
      # check for pidfile
      if [ -f $PIDFILE ] ; then
  	PID=`cat $PIDFILE`
! 	PS=`ps -p $PID 2>/dev/null | tail -1 | grep $PID`
! 	if [ "x$PS" = "x" ]; then
  	    STATUS="httpd (pid $PID?) not running"
  	    RUNNING=0
  	else
--- 49,55 ----
      # check for pidfile
      if [ -f $PIDFILE ] ; then
  	PID=`cat $PIDFILE`
! 	if kill -0 $PID 2> /dev/null; then
  	    STATUS="httpd (pid $PID?) not running"
  	    RUNNING=0
  	else

Users of the Apache webserver are hereby granted a non-exclusive,
irrevocable, world-wide, royalty-free, non-transferable license to use,
execute, prepare derivative works of, and distribute (internally and
externally, and including derivative works) the code accompanying this
license as part of, and integrated into the Apache webserver.  This code is
provided "AS IS" WITHOUT WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF THE APACHE WEBSERVER.  I
represent and warrant that I am legally entitled to grant the above
license.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
"We can't protect the idiot." - David Vance of Glaxo Wellcome

Re: sun4 and apachectl

Posted by Ben Hyde <bh...@gensym.com>.
Dean writes:
> Yet another option is "kill -0 $pid".

A trick I've never used, cool.

Worry wart that I am it concerns me that kill requires that
you are "owner" of the process in question. That will break
it for existing uses (i.e. status polling deamons).  On the
other hand it's a nice improvement in the restart, and stop
cases.

 - ben hyde

Re: sun4 and apachectl

Posted by Dean Gaudet <dg...@arctic.org>.
bind's ndc uses "ps -p $pid"... which I think is why Marc implemented
apachectl that way.

Yet another option is "kill -0 $pid".

Dean

On Wed, 3 Jun 1998, Manoj Kasichainula wrote:

> On Wed, Jun 03, 1998 at 10:58:15AM -0700, Dean Gaudet wrote:
> > There's already a bug in the bugdb about this.
> 
> 2285
> 
> > Unfortunately I don't think "ps p $pid" or "ps $pid" works everywhere
> > either.
> 
> This is the kind of problem that has been solved a zillion times.
> There should be a platform-independdant solution out there somewhere,
> right?
> 
> I checked the Unix FAQ <http://www.faqs.org/faqs/unix-faq/faq/> which
> didn't have a portable solution. I'm guessing the OS will have to be
> checked for in apachectl.
> 
> -- 
> Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
> "Would you die for The One?"
> "I wouldn't get pizza for the one. That ain't my job." - J.M. Straczynski
> 


Re: sun4 and apachectl

Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Jun 03, 1998 at 10:58:15AM -0700, Dean Gaudet wrote:
> There's already a bug in the bugdb about this.

2285

> Unfortunately I don't think "ps p $pid" or "ps $pid" works everywhere
> either.

This is the kind of problem that has been solved a zillion times.
There should be a platform-independdant solution out there somewhere,
right?

I checked the Unix FAQ <http://www.faqs.org/faqs/unix-faq/faq/> which
didn't have a portable solution. I'm guessing the OS will have to be
checked for in apachectl.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
"Would you die for The One?"
"I wouldn't get pizza for the one. That ain't my job." - J.M. Straczynski

Re: sun4 and apachectl

Posted by Dean Gaudet <dg...@arctic.org>.
There's already a bug in the bugdb about this.

Unfortunately I don't think "ps p $pid" or "ps $pid" works everywhere
either.

Dean

On Tue, 2 Jun 1998, Ben Hyde wrote:

> 
> the  ...  ps -p $PID ...
> in apachectl doesn't work on the
> sun4, so you can start, but not restart or
> stop on that platform.  - ben hyde
> 
>