Fork returns twice-
once in parent
once in child
But, how is exec() different from other system calls in terms of call and return behaviour?
Actually, there are a few which don't obey the "returns once" paradigm.
A call to fork()
returns once or twice - the latter on success where it returns once in the parent and once in the child, the former on failure where it simply returns once in the parent.
A call to exec()
will return on failure but, if successful, the current process is simply overwritten with a new program.
There are others, such as exit()
or abort()
, which are not expected to return at all.