On Wed, Jul 09, 2014 at 18:33, Arne Becker wrote:
> atelnet uses atomicio, which depends on blocking sockets. Since we call
> atelnet from readwrite, the sockets are likely non-blocking.
> If we enter the for()-loop in atelnet, we set the sockets to blocking
> and remember that, so we do it only once.
> If we made them blocking, we make them non-blocking again at the end.

> +     /* make all fds non-blocking */
> +     for (n = 0; n < 4; n++) {
> +             if (pfd[n].fd == -1)
> +                     continue;
> +             flags = fcntl(pfd[n].fd, F_GETFL, 0);
> +             /*
> +              * For sockets and pipes, we want non-block, but setting it
> +              * might fail for files or devices, so we ignore the return
> +              * code.
> +              */
> +             fcntl(pfd[n].fd, F_SETFL, flags | O_NONBLOCK);
> +     }

Thanks. I think this is the trouble spot. Without this, we don't need
to fool around in atelnet either. And we probably don't really need
this. The point isn't really to create an nc that never blocks. In
particular, turning stdin and stdout non-blocking has weird effects
that has broken sh pipelines in the past.

Drop the above, the relevant chunk in atelnet, and I think it looks good.

Reply via email to