In fork a new address space is created for the child process, whereas in the exec family the process's address space remains same. In exec, the process is replaced whereas in fork a new process is created. All the process segments of the previous process in exec are freed and new memory segments are allocated. The main thing is that the pid remains the same in exec whereas in fork there's a new pid for the child process.
Fork is used to create new process, where it duplicates the current process and creates the new one along with he old process. The created new process will use the same process context of the parent process but has its own data space, enivronment and file descriptors. Fork returns pid of the created new process on success, -1 on the failure and 0 when the new process executes the fork. syntax: fork(); Whereas the exec family is used to create a new process by replacing the old process. Newly created process will be replace the process context of the old process and the task structure of the old process will be taken over by the new process. Execl returns nothing on sucess and -1 on the failure. syntax : execl(char* path, char* filename, char* arg1..., char* argn, NULL);
FORK() is used to create a new process . Its duplicate the current process and create a new process together with old process. The new process shares the process context of the old process but the new process consists of its own data block and vice versa. During execution of fork its return pid of new process , in case of failure its return -1 and when the new process is execute fork again its return 0.
EXEC family is used to replace current working process with the new one .The new process hijack the old process together with process context and the task structure where everything is replaced with the new one.
when using execl() during success its return nothing but in failure its return -1.