[BusyBox] Nc fix

Pavel Roskin pavel_roskin at geocities.com
Fri Jun 2 22:15:19 UTC 2000


Hello!

"nc" exits silently on errors. This patch makes it print something before
exit().

Note that calling perror() after gethostbyname() will most likely return
"No such file or directory" which is quite confusing, so I decided to use
fatalError instead.

Regards,
Pavel Roskin

==============================
diff -u -r1.1 nc.c
--- nc.c	2000/05/17 20:57:42	1.1
+++ nc.c	2000/06/02 19:58:42
@@ -69,7 +69,7 @@
 	hostinfo = (struct hostent *) gethostbyname(*argv);
 
 	if (!hostinfo) {
-		exit(1);
+		fatalError("nc: cannot resolve %s\n", *argv);
 	}
 
 	address.sin_family = AF_INET;
@@ -81,6 +81,7 @@
 	result = connect(sfd, (struct sockaddr *) &address, len);
 
 	if (result < 0) {
+		perror("nc: connect");
 		exit(2);
 	}
 
@@ -100,6 +101,7 @@
 				   (struct timeval *) 0);
 
 		if (result < 1) {
+			perror("nc: select");
 			exit(3);
 		}
 
==============================






More information about the busybox mailing list