LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-13-2013, 02:34 PM   #1
moraxu
LQ Newbie
 
Registered: Dec 2012
Distribution: Ubuntu
Posts: 15

Rep: Reputation: Disabled
Job control in bash and SIGTTIN, SIGTTOU, and SIGTSTP signals


Hi.

I've read in the bash manual that:

Quote:
When job control is in effect [set +m command turns it off], Bash ignores the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.
Could somebody explain it to me? When I turn off the job control and press Ctrl-Z when a sleep command is running, it'll have no effect...

Unless the quote is refering to a bash process itself. However, in that case, it always ignores (nothing happens) SIGTSTP signal when I send it to the shell from the other terminal - no matter if job control is enabled or not.
 
Old 04-14-2013, 02:26 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Quote:
Originally Posted by moraxu View Post
However, in that case, it always ignores (nothing happens) SIGTSTP signal when I send it to the shell from the other terminal - no matter if job control is enabled or not.
When I did that to my bash it does get itself stopped and makes the input return to the previous bash shell. And I verified it through $BASHPID. I tested it both when job control is enabled and not (on the child shell/target shell, and not the parent shell).

Edit: Oh sorry I actually used SIGSTOP not SIGTSTP. I think SIGTSTP could be ignored as referred to this thread: http://stackoverflow.com/questions/9...p-signal-ctrlz. I'll try to study it further.

Last edited by konsolebox; 04-14-2013 at 02:31 AM.
 
Old 04-14-2013, 02:54 AM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
I think when job control is enabled, the child process is somehow protected by bash so in a way it makes the effect of those signals uneffective. And I think when job control is enabled, the input and output is actually handled to bash and somehow just redirected to the child process, but I can't be sure of that unless I actually study the source code to know how bash implements it, or perhaps ask its developer(s).
 
Old 10-22-2014, 08:20 AM   #4
osirisgothra
LQ Newbie
 
Registered: Feb 2013
Posts: 4

Rep: Reputation: Disabled
job control

I am pretty sure those signals, when not in bash's hands are supposed to be trapped to some other handler routine written by yourself, when job control's on or off, you can't even trap those signals, which makes sense because job control needs them, and if not handled properly you may mess things up badly, at least in that child process' tree. The CTRL-Z in a child is supposed to trigger SIGTSTP, which, if bash isn't listening, wont do anything (unless someone down the line has control). The SIGTTIN/OU are the I/O for the background process, which is needed to know whether the process wants input or has output. Anyways as you guys said, the specifics are in the bash code, and the child process in question's code. I have heard from many people that you should stay away from these signals unless you REALLY need them, or are the leader process.

Last edited by osirisgothra; 10-22-2014 at 09:51 AM. Reason: typo
 
  


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
Relationship between ASCII control codes and Process Signals jhwilliams Linux - Software 2 06-12-2009 04:51 PM
Resume SIGTSTP question b4283 Linux - General 3 06-12-2009 01:24 AM
LXer: BASH job control: fg, bg, jobs, and Ctrl-Z LXer Syndicated Linux News 0 08-11-2007 06:31 AM
Job control King4lex Linux - Newbie 3 08-16-2004 01:50 PM
returning to command line from a SIGTSTP Ctawp Programming 1 12-07-2003 10:52 PM


All times are GMT -5. The time now is 09:11 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