Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Stopping an HTTP::Server::Simple server

by Corion (Pope)
on Jan 26, 2011 at 13:14 UTC ( #884335=note: print w/replies, xml ) Need Help??

in reply to Re: Stopping an HTTP::Server::Simple server
in thread Stopping an HTTP::Server::Simple server

Maybe take a look at what you actually get in $pid before trying to kill it? .

Replies are listed 'Best First'.
Re^3: Stopping an HTTP::Server::Simple server
by textual (Novice) on Jan 26, 2011 at 14:19 UTC
    It's actually not defined.

      This is surprising, as HTTP::Server::Simple should then die in the parent with Can't fork: ..., which you should have seen:

      sub background { my $self = shift; my $child = fork; croak "Can't fork: $!" unless defined($child); return $child if $child; srand(); # after a fork, we need to reset the random seed # or we'll get the same numbers in both branches if ( $^O !~ /MSWin32/ ) { require POSIX; POSIX::setsid() or croak "Can't start a new session: $!"; } $self->run(@_); # should never return exit; # just to be sure }

      So, either you're looking at a webserver that is not the webserver you launched, or the $pid is not where you store the information.

      If you're trying to kill the child from within the child, $pid will also not be defined there (see fork). To kill yourself, use $$ as the pid.

        Another possibility is that the op is trying to launch the webserver in one process invocation, and then kill it in another. In which case $pid will have to be written to/from a file.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://884335]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-05-26 22:05 GMT
Find Nodes?
    Voting Booth?