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?)
If sudo
merely called exec
, then sudo
couldn't do things like run any cleanup tasks when the exec'd code completed. Take pam_open_session
and pam_close_session
for example.
Hope this helps!
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