Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 7
    One more addition: exec saves one pid and some small amounts of memory required to store shell image (if there is only one left) and some process metadata about it because shell does not exist and does not wait for forked process to complete. This maybe critical in embedded systems with 16M or even 8M onboard RAM available. Commented May 30, 2016 at 5:49
  • @siblynx, I appreciate your excellent observation. Commented May 30, 2016 at 6:06
  • 6
    Since exec replaces the shell in place, it also makes the executed program a direct child of the shell's parent, instead of a grandchild through the shell. That might matter if the program running the script (and ultimately the exec'd program) cares about how its child dies Commented May 30, 2016 at 6:47
  • @ikkachu Excellent point. I'll add it to the answer if you don't mind. Commented May 30, 2016 at 6:49
  • @Jasper exec something vs just something are the two options Commented May 30, 2016 at 9:23