Question

#include #include <sys/types.h> <unistd.h> int main void ) fork fork fork execip ( /bin/ls, return 0 /* Line A /* Line B/ /

With explanation Please.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

0T) cluding the inibal pareり! no CYca te olu bo Total 8 proce sses crea ted For I Fosks 23 Pr0essy <tecle also execut 8imes maren eeclpC FC) 3 Chi F C FC ) 2 C3execlp FCO FC FC) FC) FCO execlp FC FC) FC) execlpC FC) erecle) To tal process created fonb ae in te chan an NV execle U K CFC FC IFCO exe cip FC) FC) 2 FCO FC ση( Answ) assuminq th NULL FCO ereclr f o 2 fcK processes ceate NOLL will be exe ute IS S a command to lic com putefilesmain.c F9 #include #includeくunistd.h #include<stdio.h>| 1 <sys/types.h> 3 4 1nt main 6 7 8 fork(); fork(); fork(); execlp(/bmain.c #include <sys/types.h> #include<unistd.h> #include<stdio.h> 4 int main() 6 7 8 fork(); fork(); execlp(/bin/ls, ls,main.c #include <sys/types.h> #include unistd.h> #include<stdio.h> 1 4 int main 6 7 8 9 10 fork(); execlp(/bin/ls, ls , N

Add a comment
Know the answer?
Add Answer to:
With explanation Please. #include #include <sys/types.h> <unistd.h> int main void ) fork fork fork execip (...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Source code to modify: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main() { pid_t pid; /*fork...

    Source code to modify: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main() { pid_t pid; /*fork a child process*/ pid = fork(); if (pid<0){ /*error occured*/ fprintf(stderr,"Fork failed\n"); return 1; } else if (pid == 0) { /*child process */ printf("I am the child %d\n",pid); execlp("/bin/ls","ls",NULL); } else { /*parent process */ /*parent will wait for the child to complete*/ printf("I am the parent %d\n",pid); wait(NULL); printf("Child Complete\n"); } return 0; } 1. Write program codes for 3.21 a and...

  • Problem la Points (20) Draw the process tree for the program shown below. #include<sys/types.h> #include<stdio.h> #include<unistd.h>...

    Problem la Points (20) Draw the process tree for the program shown below. #include<sys/types.h> #include<stdio.h> #include<unistd.h> int value = 5; int main() pid_t pid; pid = forko; if(pid ==0) { */ Child Process */ forkO; value += 15; return 0; else if (pid > 0) {/* Parent process */ forkO; forkO; wait(NULL); printf("Parent: value = %d", value); /* LINE A */ return 0;

  • What is the output? #include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main()...

    What is the output? #include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int x = 5; int y = 2; int z = 30; x = fork(); y = fork(); if (x != 0) printf("Type 1\n"); if (y != 0) printf("Type 2\n"); z = fork(); if (x > 0 || y > 0 || z > 0) printf("Type 3\n"); if (x == 0 && y == 0 && z != 0) printf("Type 4\n"); if (x...

  • #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void...

    #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void insertionSort(int arr[], int n); void merge(int a[], int l1, int h1, int h2); void mergeSort(int a[], int l, int h) { int i, len=(h-l+1); //Using insertion sort for small sized array if (len<=5) { insertionSort(a+l, len); return; } pid_t lpid,rpid; lpid = fork(); if(lpid<0) { //Lchild proc not created perror("Left Child Proc. not created\n"); _exit(-1); } else if (lpid==0) { mergeSort(a,l,l+len/2-1); _exit(0); } else...

  • Combine two codes (code 1) to get names with(code 2) to get info: Code 1: #include<unistd.h>...

    Combine two codes (code 1) to get names with(code 2) to get info: Code 1: #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<dirent.h> #include<stdio.h> #include<stdlib.h> void do_ls(char []); int main(int argc,char *argv[]) { if(argc == 1) do_ls("."); else while(--argc){ printf("%s:\n",*++argv); do_ls(*argv); } } void do_ls(char dirname[]) { DIR *dir_ptr; struct dirent *direntp; if((dir_ptr = opendir(dirname)) == NULL) fprintf(stderr,"ls1:cannot open %s\n",dirname); else { while((direntp = readdir(dir_ptr)) != NULL) printf("%s\n",direntp->d_name); closedir(dir_ptr); } } ____________________________ code 2: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> void show_stat_info(char *,...

  • plz help me

    #include <sys/types.h> #include <stdio.h> #include <unistd.h> int value = 10; int main() { pid_t pid;  pid = fork();  if (pid == 0) {  value = value + 100;  } else if (pid > 0) { value = value -100;  printf("PARENT: value= %d \n", value); //Line A  wait (NULL); } }  (i) What will be the output in Line A? Justify your answer. (ii) Do you think there is synchronization problem in updating the variable value? Justify your answer.

  • 5. Answer the questions on the following program: #include <signal.h> #include <stdio.h> #include <unistd.h> void ouch(int...

    5. Answer the questions on the following program: #include <signal.h> #include <stdio.h> #include <unistd.h> void ouch(int sig) { printf("OUCH! -­‐ I got signal %d\n", sig); } int main() { signal(SIGINT, ouch); signal(SIGQUIT, ouch); while(1) { printf("Hello World!\n"); sleep(1); } } 1) What is the output of just running the program? 2) What will happen if you try to use both keyboard signals of terminal interrupt and terminal quit: Ctrl-­‐C and Ctrl-­‐\ to kill the process? 3) Give exactly necessary commends...

  • computers. 1. How many times will this loop repeat? include <stdlib.h> #include <stdio.h> void main(void) int...

    computers. 1. How many times will this loop repeat? include <stdlib.h> #include <stdio.h> void main(void) int 10 for(= 0; i < 101) printf("d", 1); A. 10 times B. 1 time C. It will run forever D. 0 times 2. What will be the output of this program? #include <stdlib.h> #include <stdio.h> int main() int a = 100, b = 200, C = 300; if(!a >= 500) b = 300; C = 400; printf("%d, 8d, &d", a, b, c); return 0;...

  • Figure 〈 1013 > int main pid t pidfork if (pid0) printt "In child process: x*d\n",-x)...

    Figure 〈 1013 > int main pid t pidfork if (pid0) printt "In child process: x*d\n",-x) exit (0) printf ("In parent process: x return 0 *d\n", ++x) Part A- The Output of fork Let's examine the behavior of fork0 through a simple example. Consider the program in Figure 1. Figure 1) This program will produce two lines of output when executed. What are the values of x in each of these lines? Separate your answers for the first and second...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT