I am taking an OS class and trying to wrap my head around this question, any help would be appreciated:
What happens to the other threads, if one of many threads within a process makes an exec() call? Why?
My understanding of exec() is that is replaces the current process with a new one, and it's main difference from fork() is that fork() creates a clone and you end up with duplicates.
So if exec() replaces the current process, would it kill the threads of the old process and replace them with the new one? Any help will be appreciated.
On POSIX-compliant Unix-like systems:
A call to any exec function from a process with more than one thread shall result in all threads being terminated and the new executable image being loaded and executed. No destructor functions or cleanup handlers shall be called.
After exec*
completes, there is just one thread.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
(Incidentally, I think they meant to write "A successful call to any exec function...", as the text makes no sense for unsuccessful calls.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With