LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2017, 12:21 PM   #1
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 7
Posts: 693

Rep: Reputation: 69
trap ctrl+z in bash script


Code:
#!/bin/bash

trap 'echo " - it isnt working!"' SIGINT SIGTERM SIGTSTP
x=1
while [ $x -le 10000 ]
	x=$[$x+1]
	do echo $x
	sleep 1
Hi,
I've got this little script by which I tried to also catch the ctrl+z signal (SIGTSTP). But I don't understand exactly its behaviour. When I do press ctrl+z, the script stops counting, so it's suspended, but I still don't have access to the shell. The process remains there. Why is that?
 
Old 12-06-2017, 12:24 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,960
Blog Entries: 12

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
Have you tried enabling script debug? Put:
Code:
set -xv
after the first line of the script and when you run it in a terminal, see what output it gives you.
 
Old 12-06-2017, 12:29 PM   #3
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 7
Posts: 693

Original Poster
Rep: Reputation: 69
It does explain what it's doing while running, but when I press ctrl+z, everything stops. It's not doing anything, so there's no debugging. It's just suspended.
 
  


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
[SOLVED] trap error and assign in bash script vrusu Linux - Newbie 8 04-15-2015 08:58 AM
Trap MySQL errors on remote server using bash script linuxlover.chaitanya Linux - General 0 06-13-2014 06:44 PM
How to end the bash script using commands in bash not manually by pressing ctrl+c Sanpreet Singh Linux - Newbie 1 07-03-2013 02:04 PM
[SOLVED] Using trap in bash script sree_ec Programming 13 03-28-2012 11:48 PM
invisible chrs and no newline in bash after running script with 'trap 2' and 'read' SlackerJack Linux - General 3 08-11-2008 12:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:16 AM.

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