943,865 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2843
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 15th, 2007
0

Re: What are forks????

666
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jul 15th, 2007
0

Re: What are forks????

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
Moderator
Featured Poster
Reputation Points: 1767
Solved Threads: 574
Moderator
jbennet is offline Offline
16,517 posts
since Apr 2005
Jul 15th, 2007
2

Re: What are forks????

Forks don't create new threads; they create new processes.
Team Colleague
Reputation Points: 1135
Solved Threads: 171
Super Senior Demiposter
Rashakil Fol is offline Offline
2,478 posts
since Jun 2005
Jul 18th, 2007
0

Re: What are forks????

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?
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 18th, 2007
0

Re: What are forks????

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.
Reputation Points: 115
Solved Threads: 5
Junior Poster
Toba is offline Offline
192 posts
since Jun 2004
Jul 19th, 2007
0

Re: What are forks????

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?
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 20th, 2007
0

Re: What are forks????

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?
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Jul 20th, 2007
0

Re: What are forks????

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?
Featured Poster
Reputation Points: 424
Solved Threads: 57
Posting Virtuoso
Nichito is offline Offline
1,594 posts
since Mar 2007
Aug 3rd, 2007
0

Re: What are forks????

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.
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Aug 3rd, 2007
0

Re: What are forks????

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: !!!!!!!!!!!
Next Thread in C++ Forum Timeline: MUD help?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC