Question: PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY

PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTEFROM ANOTHER CHEGG!!!!!PLZ DO NOT COPY PASTE FROM ANOTHER CHEGG!!!!!PLZ DO NOT

This handout describes the exec family of functions, for executing a command. You can use these functions to make a child process execute a new program after it has been forked. The functions in this family differ in how you specify the arguments, but they all do the same thing. They are declared in the header file 'unistd.h'. execv (char *filename, char *const argv[]) The execv function executes the file named by filename as a new process image. The argy argument is an array of null-terminated strings that is used to provide a value for the argu argument to the main function of the program to be executed. The last element of this array must be a null pointer. execup (char *filename, char *const argv[]) The execvp function is similar to execv, except that it searches the directories listed in the PATH environment variable to find the full file name of a file from filename if filename does not contain a slash. This function is useful for executing system utility programs, because it looks for them in the places that the user has chosen. Shells use execvp to run the commands that users type. execl (char *filename, const char *argo, ...) This is similar to execv, but the argv strings are specified individually instead of as an array. A null pointer must be passed as the last such argument. execlp (char *filename, const char *argo, ...) This function is like execl, except that it performs the same file name searching as the execvp function. Example 1: Using execv(...) command Note: This version will not search the path, so the full name of the executable file must be given. Parameters to main() are passed in a single array of character pointers. #include #include int main (int argc, char *argv[]) { execv ("/bin/echo", &argv[0]); printf ("EXECV Failed "); /* The above line will be printed only on error and not otherwise */ Part 2 Write a program where a child is created to execute a command that shows all files (including hidden files) in a directory with information such as permissions, owner, size, and when last modified. Use execvp(...). Announce the successful forking of child process by displaying its PID

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!