Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


Search this Thread
Old 02-13-2014, 01:25 PM   #1
LQ Newbie
Registered: Feb 2014
Posts: 3

Rep: Reputation: Disabled
how to ignore the TSTP signal in script so that Ctrl-Z deactivate on the script.

how to ignore the TSTP signal in script so that Ctrl-Z deactivate on the script.

Tried below
echo "SIGTSTP received" > /dev/tty
trap - TSTP
echo "SIGTSTP standard handling restored"

trap - sigtstp

using above if i Ctrl-Z, it stops the script (without prompt hanging),as without above lines ctrl-Z was hanging prompt
but i want the script should not even stop and the signal should ignored compeletly.

Tried these as well but no luck (prompt hangs)
trap : TSTP # ignore Ctrl-Z requests
trap - TSTP # allow Ctrl-Z requests

please suggest
Old 02-14-2014, 08:45 AM   #2
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,535

Rep: Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466Reputation: 1466
you cannot catch it in your script because it is handled by the terminal, not by the script. You can use stty susp <something> to set it to something, for example stty susp ^T will set it to Ctrl-T. and sttyz susp ^Z will restore the original.
Old 10-15-2014, 02:03 PM   #3
LQ Newbie
Registered: Sep 2008
Location: Ottawa, CANADA
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
If you use a simple shell such as "dash", then you can ignore TSTP:

trap '' TSTP

This sometimes works in the "bash" shell, except that commands run by that shell may not also ignore TSTP.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ignore the TSTP signal mohitbadgaiyan Linux - Newbie 0 02-13-2014 10:44 PM
Shell Script: Getting signal handlers to work when running an application by script pkjss Programming 4 09-14-2011 05:23 AM
[shell script] ignore folder if it contains file x vraptor Linux - Newbie 4 05-10-2011 07:38 AM
How do I use CTRL+D signal in bash script manya Programming 1 01-15-2010 08:10 AM
Ignore/Disable Ctrl-C (SIGINT) in a shell script dctw Programming 3 01-11-2010 03:30 AM

All times are GMT -5. The time now is 07:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration