LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 09-30-2011, 03:17 PM   #1
mreff555
Member
 
Registered: Sep 2011
Location: Philly
Distribution: Gentoo
Posts: 473

Rep: Reputation: Disabled
forking and background processes


I was hoping for a bit of clarification about a few things related to forking and background process.

First: I infer that sending a process to the background doesn't automatically redirect the output since files that generate output still update to the screen. Am I right on this? if so, how could I echo the output to a file and send it to a background process.

second: There's many times when I've been connected remotely via ssh and run a command which will take a very long time to complete. If I send it to the background will that program continue to execute after I log off? if not what else would I have to do?

Third: Forking, whats it good for? could someone give me an example of how it might be used.

forth: I know a decent amount about the command line but I feel like these question I'm asking are more difficult to find than many others. Where could I find sources if information about various command line operators eg: %, |, &, !, /

Thanks
 
Old 09-30-2011, 09:10 PM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 93

Rep: Reputation: 9
Partial answer

Hi, what I found very useful for command line questions is the Advanced Bash Scripting Guide: http://tldp.org/LDP/abs/html/index.html
There are many things explained about Bash and not just scripting.
I hope it helps you with at least one of your questions.
 
Old 09-30-2011, 09:54 PM   #3
snooly
Member
 
Registered: Sep 2011
Posts: 124

Rep: Reputation: Disabled
Quote:
Originally Posted by mreff555 View Post
I was hoping for a bit of clarification about a few things related to forking and background process.

First: I infer that sending a process to the background doesn't automatically redirect the output since files that generate output still update to the screen. Am I right on this? if so, how could I echo the output to a file and send it to a background process.

second: There's many times when I've been connected remotely via ssh and run a command which will take a very long time to complete. If I send it to the background will that program continue to execute after I log off? if not what else would I have to do?

Third: Forking, whats it good for? could someone give me an example of how it might be used.

forth: I know a decent amount about the command line but I feel like these question I'm asking are more difficult to find than many others. Where could I find sources if information about various command line operators eg: %, |, &, !, /

Thanks
1. Processes in the background send their output to the attached terminal which started them, for as long as the terminal remains attached. Sending output from a process to stdout and a file can be accomplished with the "tee" comand.

2. If you put a process in the background and log off, it will get the SIGHUP signal I think, and then will probably die. You can either "disown" the background process, or run it using "nohup" from the start. Either way, then the process will keep running after you log off.

3. One example of forking is for a server. It listens on a port. When it gets a connection, it forks off a child copy of itself to handle the connection, and the parent continues listening for the next connection. That way, the incoming job gets handled, and the server remains ready to handle more jobs.

4. "man bash" should explain all the details of those symbols. If you have a specific question, like "what does !! do?" for example, please ask.
 
Old 10-03-2011, 04:42 PM   #4
mreff555
Member
 
Registered: Sep 2011
Location: Philly
Distribution: Gentoo
Posts: 473

Original Poster
Rep: Reputation: Disabled
Thanks for the tips.
 
  


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] Best use of dlopen when forking many similar processes redhatstand Programming 3 12-30-2010 07:17 AM
forking 7 child processes ianomc Programming 5 11-07-2004 01:33 PM
background processes digit Linux - Software 3 07-27-2003 01:27 PM
processes in background zetsui Linux - General 8 06-14-2003 01:52 PM
background processes hakum Programming 1 04-08-2002 11:29 PM

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

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