On Mon, 8 Aug 2016, Marc Espie wrote:
> Well, unless someone can repair connect, here's a very ugly hack that 
> should prevent SIGWINCH from fucking ftp up.

Hmm, there's a bug in connect(), but not the one you want.

Like nanosleep(), poll(), and select(), the connect() call never restarts 
after a signal.  For connect() it's _supposed_to_be_ because the signal 
doesn't actually interrupt the underlying connect operation.  To quote
POSIX:
        If connect() is interrupted by a signal that is caught while
        blocked waiting to establish a connection, connect() shall
        fail and set errno to [EINTR], but the connection request
        shall not be aborted, and the connection shall be established
        asynchronously.

...but we don't implement that, and interrupting connect() takes the 
socket out of the connecting state.  Looks like FreeBSD and NetBSD 
switched behaviors some time ago, maybe now's a good time in the cycle for 
us to switch...


So for now, for pkg_add, your solution of blocking the signal across the 
call is the best choice.  Once the kernel changes behavior you would have 
the option of instead handling EINTR by looping in a poll() for 
writability; not sure if that would be simpler but it would allow WINCH 
processing to occur during the connect...


Philip Guenther

Reply via email to