LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-15-2006, 02:47 AM   #16
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61

fg built-in won't work, since the shell's notion of the "last background job" is overthrown by the nohup, which makes the command detach from the terminal essentially.

With the code
your_ccommand &
disown -h
I was trying to make you start your command without "nohup" and then run the disown. disown will also make the last job be unresponsive to SIGHUP (hang-up signal) of the shell, so your command may continue running if the shell exits.
So, in a way, disown will "simulate" the nohup behaviour, except that the -h prevents the job from being deleted from the jobs table, so the shell will still have the notion of the started job.

By filtering ps output (and probably also in other ways), you can find such nohup'ed programs that aren't attached to a terminal. But when you find the process IDs of such programs, your only option would be to "kill" them. Bringing them to the foreground would require re-attaching them to your terminal/shell, which is probably a lot harder to accomplish.
 
Old 12-15-2006, 09:45 AM   #17
RAdams
Member
 
Registered: May 2006
Location: Cincinnati, Ohio
Distribution: Ubuntu
Posts: 256

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by timmeke
fg built-in won't work, since the shell's notion of the "last background job" is overthrown by the nohup, which makes the command detach from the terminal essentially.

With the code
your_ccommand &
disown -h
I was trying to make you start your command without "nohup" and then run the disown. disown will also make the last job be unresponsive to SIGHUP (hang-up signal) of the shell, so your command may continue running if the shell exits.
So, in a way, disown will "simulate" the nohup behaviour, except that the -h prevents the job from being deleted from the jobs table, so the shell will still have the notion of the started job.

By filtering ps output (and probably also in other ways), you can find such nohup'ed programs that aren't attached to a terminal. But when you find the process IDs of such programs, your only option would be to "kill" them. Bringing them to the foreground would require re-attaching them to your terminal/shell, which is probably a lot harder to accomplish.
You speak the truth about fg. I failed to mention that an execution of fg simply returns "-bash: fg: current: no such job". And as I mentioned above, any type of execution of my command attempts to start a new instance of the program, which is unhelpful.

I don't care how the program is pulled out, whether through forced exiting or bringing it to the foreground. But through some option, I need to close the program. Ideas?
 
Old 12-15-2006, 10:00 AM   #18
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Oh yes. I forgot that you were dealing with an already running program. Sorry.

If you don't care if the process is killed, then you could try looking for:
1. "orphaned" processes: try selecting processes with PPID=1 (parent process ID) from ps output
2. If you have the name of your command, you should be able to get it's process ID from "ps" and then kill it.
When executing the kill -9 or kill -15, you could also add a "-" before the process ID to kill the entire
process group or use something like "killall".
3. Selecting processes that belong to a process group that is not related to any of your terminals (you can
get the process IDs of each terminal by "echo $$".
 
Old 12-16-2006, 12:58 AM   #19
RAdams
Member
 
Registered: May 2006
Location: Cincinnati, Ohio
Distribution: Ubuntu
Posts: 256

Original Poster
Rep: Reputation: 30
ps -A | grep ventrilo

found it. killed it. Made a new script to custom hunt the PID and pass it to fg. Solved. Thanks all.
 
  


Reply

Tags
cron


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
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 02:50 PM
Another World of Warcraft question/problem... Bokathebard Linux - Games 0 10-23-2005 04:48 AM
802.11b/g wireless nic with fedora core 3 question--which is easiest to get working? tyler0123 Linux - Hardware 4 05-23-2005 02:13 PM
prob one of the easiest question crayola311 Linux - Newbie 8 04-10-2004 12:14 PM
The fate of the world rests on this question! Colonel Panic Linux - General 6 07-25-2001 09:42 AM


All times are GMT -5. The time now is 05:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration