summaryrefslogtreecommitdiffstats
path: root/release/sysinstall/dist.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1997-01-19 09:55:37 +0000
committerjkh <jkh@FreeBSD.org>1997-01-19 09:55:37 +0000
commit1d0095968bbcdd83e153873f85d70bd88bf7f314 (patch)
treefe9faa87675730a426625b5c6186afd3ad62b7de /release/sysinstall/dist.c
parent45f24bb16eb909ab1f7566fbf4a770f73f6543b5 (diff)
downloadFreeBSD-src-1d0095968bbcdd83e153873f85d70bd88bf7f314.zip
FreeBSD-src-1d0095968bbcdd83e153873f85d70bd88bf7f314.tar.gz
Use alarm's return status to more properly denote timeout rather than keeping
an icky global around.
Diffstat (limited to 'release/sysinstall/dist.c')
-rw-r--r--release/sysinstall/dist.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c
index 7d05dc5..491a106 100644
--- a/release/sysinstall/dist.c
+++ b/release/sysinstall/dist.c
@@ -344,11 +344,11 @@ distSetXF86(dialogMenuItem *self)
static void
media_timeout(int sig)
{
- AlarmWentOff = TRUE;
if (sig != SIGINT)
msgDebug("A media timeout occurred.\n");
else
msgDebug("User generated interrupt.\n");
+ alarm(0);
}
static Boolean
@@ -415,9 +415,8 @@ distExtract(char *parent, Distribution *me)
alarm_set(mediaTimeout(), media_timeout);
status = attr_parse(dist_attr, fp);
- alarm_clear();
sigaction(SIGINT, &old, NULL); /* Restore signal handler */
- if (DITEM_STATUS(status) == DITEM_FAILURE)
+ if (!alarm_clear() || DITEM_STATUS(status) == DITEM_FAILURE)
msgConfirm("Cannot parse information file for the %s distribution!\n"
"Please verify that your media is valid and try again.", dist);
else {
@@ -469,8 +468,16 @@ distExtract(char *parent, Distribution *me)
total = 0;
(void)gettimeofday(&start, (struct timezone *)0);
- /* We have one or more chunks, go pick them up */
+ /* We have one or more chunks, initialize unpackers... */
mediaExtractDistBegin(root_bias(me[i].my_dir), &fd2, &zpid, &cpid);
+
+ /* Make ^C fake a sudden timeout */
+ new.sa_handler = media_timeout;
+ new.sa_flags = 0;
+ new.sa_mask = 0;
+ sigaction(SIGINT, &new, &old);
+
+ /* And go for all the chunks */
for (chunk = 0; chunk < numchunks; chunk++) {
int n, retval, last_msg;
char prompt[80];
@@ -489,22 +496,18 @@ distExtract(char *parent, Distribution *me)
snprintf(prompt, sizeof prompt, "Extracting %s into %s directory...", dist, root_bias(me[i].my_dir));
dialog_gauge("Progress", prompt, 8, 15, 6, 50, (int)((float)(chunk + 1) / numchunks * 100));
- /* Make ^C fake a sudden timeout */
- new.sa_handler = media_timeout;
- new.sa_flags = 0;
- new.sa_mask = 0;
- sigaction(SIGINT, &new, &old);
while (1) {
int seconds;
alarm_set(mediaTimeout(), media_timeout);
n = fread(buf, 1, BUFSIZ, fp);
- alarm_clear();
- if (n <= 0 || AlarmWentOff) {
- msgConfirm("Read error on media (timeout or user abort).\n");
+ if (!alarm_clear()) {
+ msgConfirm("Media read error: Timeout or user abort.");
break;
}
+ else if (n <= 0)
+ break;
total += n;
/* Print statistics about how we're doing */
@@ -530,9 +533,9 @@ distExtract(char *parent, Distribution *me)
goto punt;
}
}
- sigaction(SIGINT, &old, NULL); /* Restore signal handler */
fclose(fp);
}
+ sigaction(SIGINT, &old, NULL); /* Restore signal handler */
close(fd2);
status = mediaExtractDistEnd(zpid, cpid);
goto done;
@@ -558,12 +561,15 @@ distExtract(char *parent, Distribution *me)
status = msgYesNo("Unable to transfer the %s distribution from\n%s.\n\n"
"Do you want to try to retrieve it again?",
me[i].my_name, mediaDevice->name);
+ dialog_clear();
}
}
}
/* Extract was successful, remove ourselves from further consideration */
if (status)
*(me[i].my_mask) &= ~(me[i].my_bit);
+ else
+ continue;
}
restorescr(w);
return status;
OpenPOWER on IntegriCloud