diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-06-04 05:21:49 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-06-04 05:21:49 +0000 |
commit | afeb6834597dba7c2546f36f5de61f218fbd5b4b (patch) | |
tree | 5e7c0d19b1624086ce665e757eebb83f242d837c | |
parent | 46a38dbb9b1a5ecec99dda2eb42b456e5ac76c26 (diff) |
"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
-rw-r--r-- | nc.c | 4 | ||||
-rw-r--r-- | networking/nc.c | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -69,7 +69,7 @@ int nc_main(int argc, char **argv) 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 @@ int nc_main(int argc, char **argv) result = connect(sfd, (struct sockaddr *) &address, len); if (result < 0) { + perror("nc: connect"); exit(2); } @@ -100,6 +101,7 @@ int nc_main(int argc, char **argv) (struct timeval *) 0); if (result < 1) { + perror("nc: select"); exit(3); } diff --git a/networking/nc.c b/networking/nc.c index a588587fb..a7e48d39b 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -69,7 +69,7 @@ int nc_main(int argc, char **argv) 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 @@ int nc_main(int argc, char **argv) result = connect(sfd, (struct sockaddr *) &address, len); if (result < 0) { + perror("nc: connect"); exit(2); } @@ -100,6 +101,7 @@ int nc_main(int argc, char **argv) (struct timeval *) 0); if (result < 1) { + perror("nc: select"); exit(3); } |