Saturday, July 4, 2020

System Calls in Linux : fork() and exec()

Hi,

In this post I am going to discuss about the system call that the process makes to the Kernel.

There are two system calls available in Linux namely...

1. fork()
2. exec()

System Call fork()
When ever the user wants to execute a program, the kernel of Linux does the operation in the following way...

Consider a user wants to list the contents of a directory, normally 'ls' is the program which lists the contents of the directory but the process that does execute the process 'ls' is shell, which can be either a simple sh 'sh' or bourne again shell 'bash'... here the shell is forked first and then the process 'ls' is given to the shell process.

Normally, in Linux when ever a child process is executed by the parent process, the parent process should be forked first and the child process would be supplied to it.

Forking is a process to make a exact copy of a process

System Call exec()
When the exec() system call is made, the kernel would just execute the program, normally the syntax of this system call would be exec() or exec(<program in action>)

The below diagram would help you to understand the system call discussed in a simplified way...


Well that is it, hope you had good time.

Thanks.



No comments:

Post a Comment

Changing the password of the root user of mysql in Ubuntu

Hi all,    In this post we are going to see how to reset the password of root user in mysql As we all know the root user of mysql is some...