Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am working with the fork() system call and I'm having trouble with me trying to make new processes. I would like to have 3

I am working with the fork() system call and I'm having trouble with me trying to make new processes. I would like to have 3 but I can only get it to create 7 processes. What can I do just to make 3 new processes? Thanks.

#include  #include  #include  #include  char buffer[10]; int main(){ int i; int id[3] = {-1, -1, -1}; printf("Start Pid: %5d Parent: %5d ", getpid(), getppid() ); printf("Let's create some children "); for (i=0; i<3; i++){ id[i] = fork(); printf(id[i]==0?" fork child":" fork parent"); printf(": Pid: %5d, i=%d, id=[%5d,%5d, %5d] ", getpid(), i, id[0], id[1], id[2] ); } printf("process done: Pid: %5d, i=%d, id=[%5d,%5d, %5d] ", getpid(), i, id[0], id[1], id[2] ); sleep(2); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago