LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-13-2014, 12:25 PM   #1
mohitbadgaiyan
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
sigtstp()
{
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, 07:45 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 6,367

Rep: Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722Reputation: 1722
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, 01:03 PM   #3
idallen
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.
 
  


Reply


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 09:44 PM
Shell Script: Getting signal handlers to work when running an application by script pkjss Programming 4 09-14-2011 04:23 AM
[shell script] ignore folder if it contains file x vraptor Linux - Newbie 4 05-10-2011 06:38 AM
How do I use CTRL+D signal in bash script manya Programming 1 01-15-2010 07:10 AM
Ignore/Disable Ctrl-C (SIGINT) in a shell script dctw Programming 3 01-11-2010 02:30 AM


All times are GMT -5. The time now is 10:24 PM.

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