I am writing a Perl script and I need to execute Unix Ctrl+Z on the script.
How can I do it in Perl ?
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From perl you can send signals to processes with the function kill, which has the same name as the Unix command line tool that does the same thing. The equivalent to Ctrl+Z is running
you need to find out what numeric value your TSTP signal has on your system. You would do this by running
on the command line. Let’s say this returns 20
Then in your Perl script you would add
which will send the TSTP signal to the currently running process id ($$)
Update:
as described by daxim, you can skip the ‘kill -l’ part and provide the name of the signal directly: