XV6 Make a simple test program ie Mytestc to confirm whether

XV6

Make a simple test program, i.e., Mytest.c. to confirm whether your pstree works as being expected in xv6

The Mytest.c forks few times and execs \"sh\".

Solution

int i,pid;

int mainid=getpid();

for(i=0;i<1toi(argv[1]));

pid=fork();

if(pid<0)

{

printf(\"error\");

exit(1);

}

else if(pid==0)

{

printf(\"child(%d):%d\ \",i+1,getpid());

sleep(1);

exit(0);

}

}
if(firk()==0)

{

char a[100];

sprintf(a,\"%d\",mainpid);

execlp(\"pstree\",\"pstree\",\"-c\",a,null);

}

els

{

sleep(1);

}

XV6 Make a simple test program, i.e., Mytest.c. to confirm whether your pstree works as being expected in xv6 The Mytest.c forks few times and execs \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site