Manpage of execve() says
execve() executes the program pointed to by filename. This causes the program that is currently being run by the calling process to be replaced with a new program, with newly initialized stack, heap, and (initialized and uninitialized) data segments.
In case that the calling process was created by vfork(), it means that exec() provides a new address space for the new program; it doesn’t modify the parent address space..
If the calling process was created more generally by fork(), what normally happens to the old "stack, heap, and (initialized and uninitialized) data segments"? Are their spaces deallocated?
Does the behavior of execve() depend on how the calling process was created?
Before seeing the quote, I thought that execve() would overwrite the old "stack, heap, and (initialized and uninitialized) data segments", instead of creating new ones. So when I saw the quote, wonder why waste the new space?
Thanks.