Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do understand that while exec() does not return after it executes in Unix ,system() may or may not return depending on the situation.But can anyone explain why exec() system call does not return and also the differences between exec() and system() in Unix operating system

share|improve this question
Note that system(3) is not a system call, it's a library function that itself makes a few system calls. – Stéphane Chazelas Oct 30 '12 at 15:18
system() always returns. – psusi Feb 18 '13 at 15:14
up vote 4 down vote accepted

system() is equivalent to fork() + exec() + wait(); this means when a process run system() function it creates a new process and waits the end of this process. The new process executes the command in it's own environment, when it has finished the caller receives the signal child.

For further information man exec man system

"exec replaces the current process image with a new process image", this means when it exits the caller exits too as the caller has become the new process.

share|improve this answer
There's a bit more to it than that. system() actually exec()s your default shell, and passes the string to it to process, so you can for instance, use a pipeline and other shell features. – psusi Feb 18 '13 at 15:14

This a system call in Unix OS that replaces the currently running process with a information from the binary program.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.