Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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? .


Comment on Re^2: Stopping an HTTP::Server::Simple server
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://884335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2015-07-30 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls