Comment 70 for bug 445303

Revision history for this message
In , James Westby (james-w) wrote :

Created attachment 39080
Patch to fix the race

Hi,

There's a race that means that the user can type in their
password, have the text entry disappear, and then nothing
else happen for a couple of minutes until the call times
out and they get a cryptic error. If they cancel the
dialog in that time then the program will work as they
are successfully authenticated.

The reason for this is that if the SIGCHLD handler is called
before the stdout one it unregisters the stdout handler, so
it is never triggered, and that is the only way that a response
is sent, positive or negative, except for cancelling.

I'm attaching a patch which works around this in most
cases by giving the stdout handler a chance to go first.
You may prefer to reorganise a bit to not have one
handler remove the other instead. It also ensures that
the stdout handler is registered first, in case the
child exits very quickly, but I don't know if that's
possible.

I'm also attaching a couple of other patches I produced
in the course of investigating this that might be of
interest. They fix theoretical problems, but they may
never occur in the real world.

Thanks,

James