fix for "0000027: patch: nc will spin if stdin closed"
authorPaul Fox <pgf@brightstareng.com>
Mon, 18 Jul 2005 22:23:16 +0000 (22:23 -0000)
committerPaul Fox <pgf@brightstareng.com>
Mon, 18 Jul 2005 22:23:16 +0000 (22:23 -0000)
networking/nc.c

index 58cd39fac259983f286eb00e3d10e793242635ae..bf155b3b13bb3148dd3fc11d94c4dac2cbb1c489 100644 (file)
@@ -175,8 +175,11 @@ int nc_main(int argc, char **argv)
                                                exit(0);
                                        ofd = STDOUT_FILENO;
                                } else {
-                                       if (nread == 0)
-                                               shutdown(sfd, 1);
+                                       if (nread <= 0) {
+                                               shutdown(sfd, 1 /* send */ );
+                                               close(STDIN_FILENO);
+                                               FD_CLR(STDIN_FILENO, &readfds);
+                                       }
                                        ofd = sfd;
                                }