diff options
author | Brian S. Dean <bsd@FreeBSD.org> | 2002-05-12 01:47:50 +0000 |
---|---|---|
committer | Brian S. Dean <bsd@FreeBSD.org> | 2002-05-12 01:47:50 +0000 |
commit | 73f899cae1cfb9507d72ef5ec9a9d0a02af9d005 (patch) | |
tree | e713f0ed3baada1e80ddc3aa03a7abdecc27f23a /usr.bin | |
parent | 11612afabebfb0500b667501c6ffadbbc8747eb6 (diff) | |
download | src-73f899cae1cfb9507d72ef5ec9a9d0a02af9d005.tar.gz src-73f899cae1cfb9507d72ef5ec9a9d0a02af9d005.zip |
To perform even basic error checking, one must have an exit code that
indicates that not everything worked as expected. Exit non-zero if we
timed out while transmitting or receiving a file or if the file did
not exist, etc.
MFC After: 3 days (re@ willing)
Notes
Notes:
svn path=/head/; revision=96433
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tftp/main.c | 8 | ||||
-rw-r--r-- | usr.bin/tftp/tftp.c | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 7da91841a5b9..ad3658b76ff8 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -87,6 +87,7 @@ char line[MAXLINE]; int margc; char *margv[20]; jmp_buf toplevel; +volatile int txrx_error; void get(int, char **); void help(int, char **); @@ -164,7 +165,7 @@ main(argc, argv) signal(SIGINT, intr); if (argc > 1) { if (setjmp(toplevel) != 0) - exit(0); + exit(txrx_error); setpeer(argc, argv); } if (setjmp(toplevel) != 0) @@ -651,7 +652,7 @@ command() } else { if (fgets(line, sizeof line , stdin) == 0) { if (feof(stdin)) { - exit(0); + exit(txrx_error); } else { continue; } @@ -739,8 +740,7 @@ quit(argc, argv) int argc __unused; char *argv[] __unused; { - - exit(0); + exit(txrx_error); } /* diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index b2cc8683b7b7..bac262f9ad7d 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -72,6 +72,7 @@ extern int trace; extern int verbose; extern int rexmtval; extern int maxtimeout; +extern volatile int txrx_error; #define PKTSIZE SEGSIZE+4 char ackbuf[PKTSIZE]; @@ -173,6 +174,7 @@ send_data: if (ap->th_opcode == ERROR) { printf("Error code %d: %s\n", ap->th_code, ap->th_msg); + txrx_error = 1; goto abort; } if (ap->th_opcode == ACK) { @@ -289,6 +291,7 @@ send_ack: if (dp->th_opcode == ERROR) { printf("Error code %d: %s\n", dp->th_code, dp->th_msg); + txrx_error = 1; goto abort; } if (dp->th_opcode == DATA) { @@ -479,6 +482,7 @@ timer(sig) printf("Transfer timed out.\n"); longjmp(toplevel, -1); } + txrx_error = 1; longjmp(timeoutbuf, 1); } |