Why does sudo
(among other similar commands) start a new process by calling fork()
before exec()
, rather than just running the command within the same process? sudo
doesn't do anything after it runs the command. (Or does it?)
1 Answer
If sudo
merely called exec
, then sudo
couldn't have done things like run any cleanup tasks after the exec'd code completed. Take pam_open_session
and pam_close_session
for example.
Hope this helps!