Closed BornThisWay closed 1 year ago
When sudo is suspended, it is the responsibility of sudo's parent process to handle it. In most cases a shell is sudo's parent process. For example, if you were to run "sudo vi" and suspend vi, control would return to the shell.
When sudo is resumed by the shell (or whatever the parent process is), it picks up right where it left off. In other words, it resumed immediately after the call to kill() that suspended it.
The pty and nopty code used to use a common event loop but the code was difficult to follow due to lots of if (log_io) { ... } else { ... } type constructs. Now that the nopty event loop also supports I/O logging it might be possible to re-unify them but some things, such as signal handling, are still quite different.
I've read the implementation of sudo_execute many times, but there's still a lot of confusion. It's mainly about suspension and resumption.
/* Suspend parent and tell monitor how to resume on return. */
But,I didn't see howCommand suspension scenario
very similarly in their code. Why distinguish between the two models when both can be paused?I don't think I can get out on my own :D, I'm looking forward to your reply.