fix for "0000027: patch: nc will spin if stdin closed"
authorpgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Mon, 18 Jul 2005 22:23:16 +0000 (22:23 +0000)
committerpgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Mon, 18 Jul 2005 22:23:16 +0000 (22:23 +0000)
git-svn-id: svn://busybox.net/trunk/busybox@10853 69ca8d6d-28ef-0310-b511-8ec308f3f277

networking/nc.c

index 58cd39f..bf155b3 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;
                                }