What are forks????

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: What are forks????

 
0
  #11
Jul 15th, 2007
666
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,259
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 541
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: What are forks????

 
0
  #12
Jul 15th, 2007
Originally Posted by krnekhelesh View Post
So a fork splits a process into 2 processes. But why?
networking. e.g you cant send and recieve at the same time so you could recieve in one thread and send on the other
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,052
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: What are forks????

 
2
  #13
Jul 15th, 2007
Forks don't create new threads; they create new processes.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: What are forks????

 
0
  #14
Jul 18th, 2007
So as a beginner in my C++ programming can I use them to split two process one for writing data into a file and another to read another file?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 192
Reputation: Toba is an unknown quantity at this point 
Solved Threads: 5
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: What are forks????

 
0
  #15
Jul 18th, 2007
No, beginners aren't allowed to use forks. They are a level 2 restricted system call (L2SYS). Talk to your manager about getting certified.

On a more technical note, yes I suppose you could do that, but there is no unfork() as far as I know, so if you want to do something like that and the two need to interact in a meaningful way, you either need to learn how to use shared memory, or how to use threads.
what? WHAT?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: What are forks????

 
0
  #16
Jul 19th, 2007
I read that forks can used to call another executable. Suppose I have two programs prog1 and prog2.

Suppose prog1 has the fork code and calls prog2, once prog2 is over will the control return to prog1?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: What are forks????

 
0
  #17
Jul 20th, 2007
Forks are very unnecessary for most things not concerned with networking. Your post above is quite redundant, since I would assume you would fork if you wanted to try run prog1 & prog1 concurrently (obviously this isn't entirely true, but will appear that way). If you are willing to wait for prog2 to finish before proceeding with prog1, why use a fork?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 30
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: What are forks????

 
0
  #18
Jul 20th, 2007
when i needed to use forks, what i needed was a process to wait for an user input (ENTER in this case) so a parallel process could stop... can that be done?
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: What are forks????

 
0
  #19
Aug 3rd, 2007
When I use the header file #include<unistd.h>
It says the compiler cannot read the file.

I tried compiling it in DEV C++ it gave me a error message that fork() was not initialized.
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: What are forks????

 
0
  #20
Aug 3rd, 2007
That's because there's no such thing as fork() or unistd.h on your average windows box.

Win32 doesn't have anything like fork() as such, see the hoops cygwin has to go through in order to emulate it (poorly).

If you're doing the typical fork() followed immediately by exec(), then using createProcess is a reasonable substitute.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC