#38 Hangs on EOF on standard input


I don't know if it is a real bug or not, but the GNU version 0.7.1 seems to differ from some other versions of netcat in its treatment of EOF on the standard input.

On our SunOS 5.9 system:

cat /dev/null | nc mail2 25

prints the sendmail banner, but then hangs. On our Linux Fedora 7 system a non-Gnu version of nc prints the banner and then exits cleanly. This would seem to be preferable if feasible.

Of course, we don't really care about sendmail and nc, but I thought this would be an easily reproduced demonstration of something that gets to be a problem for our actual server. The same effect is visible with other small servers, viz echo and discard:

cat /dev/null | nc localhost 7
cat /dev/null | nc localhost 9

which return immediately on Linux, but hang on Gnu nc.

Daniel Feenberg
1050 Mass Ave
Cambridge MA 02138


  • Seungbeom Kim

    Seungbeom Kim - 2009-01-30

    You can use this option:

    -c, --close close connection on EOF from stdin

  • Daniel Feenberg

    Daniel Feenberg - 2009-01-31

    Thank you. I wasn't clear if the -close went on the client or the server.

    Dan Feenberg

  • Nobody/Anonymous

    Oh, could you add «-q N» option for compatibility with netcat 1.10?
    1.10 already uses -c flag to execute commands, so you can bring some happiness to users of ssh's ProxyCommand feature.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks