Execute the command in linux, Computer Engineering

Assignment Help:

Now that the user's command has been parsed into an array of char*, we can pass this to the OS to execute the command. To execute the command, use the execvp() function from unistd.h. You will pass your command array to this function which will execute the command. Remember that if this function executes properly, it will terminate the current process; so, it should be executed in a child process. The child process can be created with the fork() function which is also in unistd.h. While the child process is executing the command, the parent process should wait for the child to finish executing. This is done by using the waitpid() function which can be found in sys/wait.h. As you are waiting on the child process, you will want to make this call blocking. You can do this by giving the WUNTRACED option to the waitpid() call which is defined in sys/types.h. Remember that if the execvp() function does not complete successfully, the child process will not end. As this will only happen when an error occurs, this would be a good place to print the error message. This can be done easily by calling the perror(NULL) function. Then be sure to end the child process by calling the exit() function. Once the command is done, you should print your prompt on a new line.


Related Discussions:- Execute the command in linux

Water chemistry, Discuss the problem when a boiler is fed with lime-soda so...

Discuss the problem when a boiler is fed with lime-soda softened water

In virtual memory system addresses used by the programmer, In a virtual mem...

In a virtual memory system, the addresses used by the programmer refers to  (A) Memory space.               (B) Physical addresses.   (C) Address space.                (D) M

Integrated services digital network service, Whole idea of ISDN is to digit...

Whole idea of ISDN is to digitize the telephone network to permit transmission of video, audio and text over existing telephone lines. The purpose of ISDN is to provide fully integ

Show library, Show Library and its types. Libraries constitute a simple...

Show Library and its types. Libraries constitute a simple meaning of gathering many object files together: 1. Static: during link editing Library code is integrated with t

Sort Wars, If quicksort is so quick, why bother with anything else? If bubb...

If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many sorting algorithms?

NETWORK ADMIN, Discuss the risks of having a single root user and how more ...

Discuss the risks of having a single root user and how more limited management abilities can be given to others users on Linux/UNIX systems.uestion #Minimum 100 words accepted#

Seven segment decoder, A design for the seven segment decoder is required. ...

A design for the seven segment decoder is required. The decoder has four inputs which represent a number from 0 to 9 in binary and seven outputs which are connected to the seven

Define miss rate, Define miss rate? It is the number of misses' states ...

Define miss rate? It is the number of misses' states as a fraction of attempted accesses.

Draw state diagram, Draw the state diagram of a process from its creation t...

Draw the state diagram of a process from its creation to termination, including all transitions, and briefly elaborate every state and every transition. When a process executes

Which types of software programs are usually supported, Which types of soft...

Which types of software programs are usually supported? Our organization is unique in that we are very flexible and can meet most client requires relative to the integration of

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd