#!/usr/bin/perl use warnings; use strict; use HTTP::Daemon; use POSIX qw(setsid); use Digest::SHA qw(sha256_hex); require 'functions.pl' or die $!; my $d = HTTP::Daemon->new(LocalAddr => "localhost", LocalPort => 8080, ReuseAddr => 1) || die "Couldn't start server! Reason: $!"; print "Serving as (".$$.") on ".$d->sockhost.":".$d->sockport."\n"; # # catching the exit- or termination status of the child process to avoid zombies # $SIG{CHLD} = sub {wait ()}; # # daemonizing, In- and Output to /dev/null and forking the server => giving control back to the shell # #&daemonize; # # looping and forking a child to process the incoming request that was accepted by the main program # while ( 1 ) {# prevents from exiting when client connects without SSL while (my $c = $d->accept()) { my $pid = fork(); die "Cannot fork: $!" unless defined($pid); if ($pid == 0) { #&handle($c); sleep(10); exit(0); } } } close($d);