Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
when I type exit in the ubuntu terminal (tty1), although the logon prompt is back, the application that is spawned (a.out&) is still running .
using ps -ef |grep a.out , I get ? in place of tty.
I want to know how to exit tty and that will close a.out (by sending some signal to it). (like when I close a terminal in unity UI by clicking on the cross)
Then you don't want bash for your shell. I believe csh does that.
By putting it in the background you are TELLING bash to ignore it.
If it exits while the bash session is still running it will perform the clean up (getting the process status, and reporting it). If the bash session exits, then it will be the init process that cleans it up.
Yes, ubuntu 14.04.3 uses bash, but how do i solve this
in the UI , clicking on the 'X' closes the terminal and the back ground process (the way I wan it), is there some command to do this by some command , ('exit' is not working out)
If the huponexit shell option has been set with shopt (see The Shopt Builtin), Bash sends a SIGHUP to all jobs when an interactive login shell exits.
The highlight is mine. It needs to be a login shell, but the shells running in GUI windows aren't login shells. Sorry for leading you down the wrong path.
Apart from huponexit, I don't see an easy way to kill all background processes. You can do it with the trap command - trap somecommand 0 will execute somecommand when the shell exits. You would have to write a small script that kills all processes running on the same terminal.
exec bash --login (this should terminate things and the terminal window too)
or just "bash --login" (this will allow you to test again easier).
This restarts bash as a login. Then test things again.
DO NOT PUT THIS IN .bashrc, .profile, .login or anything else - you will suddenly NOT be able to login.
Also note - sending such signals is usally a fail, as background processes tend to have output redirected to a file (or /dev/null) and input redirected from a file (or /dev/null) which effectively detatches from a terminal. The shell ALSO can't track processes that these background processes may spawn.
It then depends on the process group leader - which in the GUI is normally the window manager (or whatever process is started by the GUI login), and not anything later (are all in the process group started by the GUI). Note: this is done so that GUI programs started by some methods get a termination signal on logout. Without this, at least SOME GUI applications will constantly try to reconnect to the display (they show up as 100 CPU bound). It depends on the programming for the application handling the error condition where the X server is aborted.
You should be able to look at the properties of the menu entry that starts the GUI terminal - and change the options on it to start bash as a login bash (bash -l or bash --login). Then I think what you are trying to do with shopt will work. NOTE: This change will also alter how the shell environment is handled and how termination is handled (see the section INVOCATION of the bash manpage).