LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-02-2007, 01:00 PM   #1
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Rep: Reputation: 30
A couple of questions about command line usage


Hi!

I've got a couple questions about command line usage:

1) If I run an xterm, then run an app from it, say firefox, forking the process at the same time ( firefox & ); I will not be able to terminate this xterm without terminating firefox at the same time. Is it possible to alter this behaviour so that it is possible to close the terminal without closing the program ran from it?

2) Is it possible to suppress *all* output from a program? The standard "> /dev/null" does not seem to be removing all the output in all conditions.

Thanks in advance
 
Old 10-02-2007, 01:32 PM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
Quote:
Originally Posted by MasterOfTheWind View Post
1) If I run an xterm, then run an app from it, say firefox, forking the process at the same time ( firefox & ); I will not be able to terminate this xterm without terminating firefox at the same time. Is it possible to alter this behaviour so that it is possible to close the terminal without closing the program ran from it?
Says who? Just tested it, works well.

Quote:
Originally Posted by MasterOfTheWind View Post
2) Is it possible to suppress *all* output from a program? The standard "> /dev/null" does not seem to be removing all the output in all conditions.
foo &> /dev/null
 
Old 10-02-2007, 01:43 PM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by uselpa View Post
Says who? Just tested it, works well.
While this works for Firefox, the behaviour isn't universal. gxine for example closes when the term is closed, as does Amarok.

FWIW, if you need to keep a console program running after closing the terminal, look at Screen (you should have it installed).
 
Old 10-02-2007, 01:46 PM   #4
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by uselpa View Post
Says who? Just tested it, works well.
Doesn't work for me unfortunately (any programs that are run that way are shown as child processes of bash, which in turn is a child of xterm) Don't really know what the problem is though.

Quote:
Originally Posted by uselpa View Post
foo &> /dev/null
Thanks ^^
 
Old 10-02-2007, 01:49 PM   #5
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Nylex View Post
While this works for Firefox, the behaviour isn't universal. gxine for example closes when the term is closed, as does Amarok.
For me this doesn't even work with firefox

Quote:
Originally Posted by Nylex View Post
FWIW, if you need to keep a console program running after closing the terminal, look at Screen (you should have it installed).
Thanks, I'll check it out
 
Old 10-02-2007, 01:51 PM   #6
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Some apps detach themselves from shell, as Firefox does. Firefox forks into firefox-bin and then it disappears.
 
Old 10-02-2007, 02:31 PM   #7
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
I've tested with Firefox, Thunderbird, and gxine, and they all continue to work, although the parent process changes. Maybe this is a behavior of Konsole, as opposed to plain xterm?

Code:
(shell 1)
pu@slackw:~$ gxine &
[1] 5118

(shell 2)
pu        5084  3343  1 21:25 ?        00:00:00     konsole [kdeinit] --ls
pu        5096  5084  0 21:26 pts/3    00:00:00       -bash
pu        5146  5096  0 21:26 pts/3    00:00:00         ps -efH
pu        5107  5084  0 21:26 pts/4    00:00:00       -bash
pu        5118  5107  7 21:26 pts/4    00:00:01         gxine

(shell 1)
Ctrl-D

(shell 2)
pu        5118     1  4 21:26 ?        00:00:08   gxine
 
Old 10-02-2007, 02:33 PM   #8
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
BTW - you could also try preceding your command with "nohup".
 
Old 10-02-2007, 02:40 PM   #9
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by uselpa View Post
Maybe this is a behavior of Konsole, as opposed to plain xterm?
Hmm... I tested konsole too, and it seems to give me the same result. Probably something with my bash-configuration or something then


Quote:
Originally Posted by uselpa View Post
BTW - you could also try preceding your command with "nohup".
Thanks, that works perfectly
 
Old 10-02-2007, 03:58 PM   #10
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Rep: Reputation: 31
No need to resort to Screen for this (although you should look into it
anyway). What you want is "disown." For example, if I start a
process from the shell, I can then just enter "disown".

Which shell are you using? You may have more than one available.
Check the documentation for the shell you're using under "job
control."

Joel
 
Old 10-02-2007, 04:03 PM   #11
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
"disown" or "disown -h" should to the trick as well, as should "shopt -u huponexit". Actually this has the whole story, for bash at least. Lookup "disown", "huponexit" and "SIGHUP".
 
Old 10-04-2007, 11:52 AM   #12
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Open /usr/bin/firefox. And see. It is not Firefox web browser, it's a shell script. I told you, it detachs firefox-bin from terminal. Do a pstree with Firefox started and see who's its parent. When parent dies, children die - no exception.
 
Old 10-04-2007, 12:45 PM   #13
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
Quote:
Originally Posted by kotnik View Post
When parent dies, children die - no exception.
That's obviously wrong, see bash as an example.
 
Old 10-04-2007, 01:03 PM   #14
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Yeah, it's wrong... I apologize It was the heat of the moment
 
Old 10-04-2007, 01:20 PM   #15
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
No worries - I learned I lot myself between post#2 and post#11 :-)
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ntlm_auth command line usage satishssquid LQ Articles Discussion 3 07-17-2007 07:42 AM
is there a way to see network usage on command line ginda Linux - Networking 3 04-27-2007 10:35 AM
sendmail usage in command line Belghouth Slackware 1 12-08-2004 10:55 AM
Sendmail command line usage Belghouth Debian 1 12-08-2004 10:54 AM
Couple questions, service command and pureftpd DigiCrime Linux - Software 3 05-29-2003 10:12 PM


All times are GMT -5. The time now is 10:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration