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)
This commit is contained in:
parent
11612afabe
commit
73f899cae1
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 @@ xmitfile(fd, name, mode)
|
||||
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 @@ recvfile(fd, name, mode)
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user