Reputation: 23
i have to write program, which will create two child processes These processes would write something in the file, but both processes are managed by the parent(which process will write) i am not asking you guys for direct solutions, but i need some hints, to know where to start from. I guess i have to create two forks at start and then manage it through case, or something like that thanks
Upvotes: 2
Views: 1015
Reputation: 165192
You will need the basic fork()
usage pattern, which looks like so:
pid = fork();
if (pid == 0)
{
// child process code starts here
}
else if (pid > 0)
{
// parent process code continues here
}
Sounds like you are going to need two fork()
s, which means you need to use this pattern nested. That's the basic usage, all the rest is up to your application.
Upvotes: 2