Are they essential????
Depends on what you are coding (Generally, I'd say no). Also, check the other forum.
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
Your questions are related to the fundamentals of forks. What are forks? Where are they used? Are they essential? These questions have been answered (yes from a C perspective), but that does not change the answers.
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
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
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
Forks don't create new threads; they create new processes.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
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?
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
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?
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
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.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953