I have the following code in my perl script which somehow doesn't seem to work:
my $thr;
sub start__server_thread()
{
$thr = threads->create(\&iperf_start_server, $_[0], $_[1], $_[2]);
print("Value of thread is $thr\n");
&START_SERVER_RESPONSE($controller_ip, $controller_port, "success", 2345, $_[1]);
}
sub iperf_start_server()
{
# Do some stuff here and then handle the signal
$SIG{'SIGSTOP'} = sub {
print("Stop signal received\n");
$thr->exit();
$flag = 1;
};
}
sub stop_server()
{
my ($dat,$filelog,$result);
$thr->kill('STOP');
$flag = 1;
sleep(10);
$thr->exit(1);
}
When from some other context stop_server() is called, it tries to send the SIGSTOP signal to the thread. It is at this point that the execution stops and I get the error "Signal SIGSTOP received, but no signal handler set in perl script. Where have i gone wrong?