openssl s_client -cert certs/capsclscert.pem -key certs/capscls_pk.pem -CAfile certs/cacert.pem -connect 10.250.3.242:6023 #### #!/usr/bin/perl use strict; use warnings; use IO::Socket::SSL; use POSIX ":sys_wait_h"; my $pidfilename = 'sftest'; # try monitor fork here: #fork_one(); # ... and everything is ok # become a daemon my $pid; if (!defined($pid = fork)) { die "Cannot daemonize myself: $! \n"; }elsif ($pid) { # I am the parent and the fork suceeded. Duck out now print "created daemon in $pid. I ($$) am ducking out\n"; exit; } # Try the monitor fork here: fork_one(); #... and the second call to accept hangs print "I'm daemonized on $$ \n"; sub REAPER { {} until ( waitpid(-1, WNOHANG) == -1) } $SIG{CHLD} =\&REAPER; my $sock; if(!($sock = IO::Socket::SSL->new( Listen => 5, LocalAddr => '10.250.3.242', LocalPort => '6023', Proto => 'tcp', SSL_verify_mode => 0x01, SSL_cert_file => 'certs/capssvcert.pem', SSL_key_file => 'certs/capssv_pk.pem', Reuse => 1, )) ) { die "unable to create socket: ", &IO::Socket::SSL::errstr, "\n"; } while (1 ) { my $s; print "$$ is listening...\n"; if ( $s = $sock->accept() ) { fork_three($s); } } #################### sub fork_one { my $pid; if (!defined($pid = fork)) { die "Cannot make monitor process: $! \n"; }elsif ($pid) { # I am the parent and the fork suceeded. Duck out now print "created monitor process in $pid. I ($$) am resuming \n"; return; } print "I ($$) am going to loop around doing some fatuous monitoring process\n"; while (1) { sleep 30; print "$$ is still monitoring\n"; } } sub fork_three { my $s = shift; my $pid; if (!defined($pid = fork)) { die "Cannot make dummy event processor: $! \n"; }elsif ($pid) { # I am the parent and the fork suceeded. Duck out now print "created dummy event processor in $pid. I ($$) am resuming \n"; return; } print "I ($$) am going to do some dummy event process\n"; $s->close(SSL_no_shutdown => 1); # my work is done... exit; }