Re: [Sshpass-devel] SIGCHLD blocking?
Brought to you by:
thesun
From: Martin G. <omg...@gm...> - 2018-07-05 17:54:11
|
Hi Shachar, thanks for the answer. 2018-07-05 14:39 GMT-03:00 Shachar Shemesh <sh...@sh...>: > In sshpass's particular case, however, you are right - there is a race in > the use case you mention. The reason there is a case is not because the > child might send a SIGCHLD before we block it. It is because we call > "waitpid" after we call pselect (thus, if the signal arrives before we block > it, we won't get around to releasing the process until the select returns > for whatever other reason). Why would pselect return, other than if there happens to be some output on the term? I don't fully understand the PTY magic here, so bear with me. While we're at that, there's a comment saying that handleoutput will return a negative value if the slave end of the PTY is closed. However, looking at handleoutput I couldn't find a case where the return value would be negative. Am I missing something? And since it can't hurt to ask: I noticed there's a check for 'terminate' at the beginning of the do-while loop. If terminate is not zero, we'll do wait_id=waitpid( childpid, &status, 0 );. Is this just a way to make sure we wait on the child process in case SSH (or whatever program we end up running) errored out? Also, what if pselect returns -1 for some reason other than us getting a signal (e.g. ENOMEM)? Wouldn't we be stuck in an infinite loop since the WNOHANG waitpid would always set wait_id to zero? |