Let's say that at some point in my program I am using execv
and the function ran successfully. Now my program has changed. What happened to it exactly? (Is all the memory get wiped automatically?)
Asked
Active
Viewed 783 times
-1
-
Possible duplicate of [Please explain exec() function and its family](http://stackoverflow.com/questions/4204915/please-explain-exec-function-and-its-family) – Dan Getz May 06 '16 at 20:03
1 Answers
1
execve() does not return on success, and the text, data, bss, and stack of the calling process are overwritten by that of the program loaded.
That is to say, all data of current process will be gone, and the new program is loaded into memory, replacing the original process.

fluter
- 13,238
- 8
- 62
- 100
-
so for example, if you fork a process and from the "child code" malloc() some memory and then calls execv(), you don't need to free() it. Right? – LiorGolan May 06 '16 at 11:44
-