Question: Answer those question Download exec-example0.c, exec-example1.c, exec-example2.c, to the linux machine. Compile each program. To compile a C program, you can use the command: gcc

Answer those question

Download exec-example0.c, exec-example1.c, exec-example2.c, to the linux machine.

Compile each program.

To compile a C program, you can use the command: gcc -o . If you are compiling the programs on nyx, use "g++" insteand of "gcc" after initializing the environment for Nachos. To be safe, just use helios for this assignment.

For example, to compile exec-example0.c, you can use: gcc -o exec-example0 exec-example0.c

This will generate a binary executable file: exec-example0

1.Run exec-example0; What is the output? Explain the output.

2.Run exec-example1; What is the output? Explain how the output was generated by the program.

3.Run exec-example2; What is the output. How is this output different from the output of exec-example1? Why are they different?

This is exex-example0 // jcoh@syr.edu, October 2013 for cis486 #include  #include  #include  #include  main() { static char *argv[]={"ls","-a",NULL}; execvp("ls", argv); } // main 

This is exex-example1
// jcoh@syr.edu, October 2013 for cis486 #include  #include  #include  #include  main() { pid_t pid; int status; pid = fork(); if (pid != 0) { // parent code printf("******************** I am the parent!!! "); } else { static char *argv[]={"ls","-a",NULL}; execvp("ls", argv); } } // main 

This exec-example2

// jcoh@syr.edu, October 2013 for cis486 #include  #include  #include  #include  main() { pid_t pid; int status; pid = fork(); if (pid != 0) { // parent code waitpid(pid, &status, 0); printf("******************** I am the parent!!! "); } else { static char *argv[]={"ls","-a",NULL}; execvp("ls", argv); } } // main 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!