fanedd has asked for the wisdom of the Perl Monks concerning the following question:

Hello everybody, I need some help with the following issue.

I am overwriting the default signal handler for TSTP signal, which will increment a flag. After this, I want the program to be suspended, so I can send it to background.

I tried to send the STOP signal after the program resumes execution, but the problem is that that can be anytime, and I want to keep the code relatively clean.

I also tried to send the signal from inside the signal handler, but that causes some core dumps from time to time. Another thing that I tried is to tie the flag, and in the STORE method send the STOP, but this also gets executed when handling the signal.

Is there a way that I can maybe call STOP on resume, or call the default signal handler after I increment my flag?

Thanks in advance!

Replies are listed 'Best First'.
Re: Suspending after catching TSTP
by haukex (Archbishop) on Feb 08, 2019 at 19:39 UTC

    Could you please show a Short, Self-Contained, Correct Example that reproduces the issue?

    Update: I haven't been able to get this to coredump yet:

    use warnings; use strict; my $run=1; $SIG{INT} = sub { print "INT\n"; $run=0 }; $SIG{TSTP} = sub { print "TSTP\n"; kill 'STOP', $$ }; sleep 1 while $run;