In Twisted what's the difference between processExited and processEnded?
twisted
Solution
I guess the documentation is somewhat sparse on this point. If no such ticket exists, please feel free to file a ticket to improve the API docs.
`processExited` is invoked when a process has exited in the formal process-management sense, i.e. called `exit()` or returned from `main()`.
However, this is not always what you want. Sometimes a process spawns a subprocess, hands off its stdin and stdout, delegates responsibility for producing the data that you (the spawning parent process, in this case) wants, and then `exit()`s because it's done setting things up.
`processEnded` is invoked when a process has both exited and finished doing all the I/O on its managed file descriptors (`stdin`, `stdout`, and `childFDs`) and they've been closed. If you're spawning something just to read its output, this is the notification you most likely care about.
Problem
As the title says, what's the difference between those two functions on ProcessProtocol classes? Documentation is a bit sparse on when should one be used instead of another? Preferably, I'm looking for some examples of use cases that demonstrate that.