Revert some of the previous change - on second thought...

This commit is contained in:
Jordan K. Hubbard 1997-02-14 21:59:26 +00:00
parent ea7c446076
commit a85842ff23
2 changed files with 36 additions and 12 deletions

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: package.c,v 1.55 1997/02/07 04:26:47 jkh Exp $
* $Id: package.c,v 1.56 1997/02/14 20:59:06 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -68,6 +68,15 @@ package_exists(char *name)
return !status;
}
/* SIGPIPE handler */
static Boolean sigpipe_caught = FALSE;
static void
catch_pipe(int sig)
{
sigpipe_caught = TRUE;
}
/* Extract a package based on a namespec and a media device */
int
package_extract(Device *dev, char *name, Boolean depended)
@ -107,6 +116,7 @@ package_extract(Device *dev, char *name, Boolean depended)
int i, tot, pfd[2];
pid_t pid;
signal(SIGPIPE, catch_pipe);
msgNotify("Adding %s%s\nfrom %s", path, depended ? " (as a dependency)" : "", dev->name);
pipe(pfd);
pid = fork();
@ -128,7 +138,7 @@ package_extract(Device *dev, char *name, Boolean depended)
tot = 0;
(void)gettimeofday(&start, (struct timezone *)0);
while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) {
while (!sigpipe_caught && (i = fread(buf, 1, BUFSIZ, fp)) > 0) {
int seconds;
if (isDebug())
@ -152,19 +162,20 @@ package_extract(Device *dev, char *name, Boolean depended)
}
close(pfd[1]);
fclose(fp);
if (i == -1)
msgDebug("I/O error while reading in the %s package.\n", name);
if (sigpipe_caught || i == -1)
msgDebug("%s while trying to install the %s package.\n",
sigpipe_caught ? "SIGPIPE" : "I/O error", name);
else
msgInfo("Package %s read successfully - waiting for pkg_add", name);
refresh();
i = waitpid(pid, &tot, 0);
if (i < 0 || WEXITSTATUS(tot)) {
if (sigpipe_caught || i < 0 || WEXITSTATUS(tot)) {
if (variable_get(VAR_NO_CONFIRM))
msgNotify("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
else
msgConfirm("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
}
else
msgNotify("Package %s was added successfully", name);
@ -174,6 +185,7 @@ package_extract(Device *dev, char *name, Boolean depended)
sleep(1);
restorescr(w);
sigpipe_caught = FALSE;
}
}
else {

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: package.c,v 1.55 1997/02/07 04:26:47 jkh Exp $
* $Id: package.c,v 1.56 1997/02/14 20:59:06 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -68,6 +68,15 @@ package_exists(char *name)
return !status;
}
/* SIGPIPE handler */
static Boolean sigpipe_caught = FALSE;
static void
catch_pipe(int sig)
{
sigpipe_caught = TRUE;
}
/* Extract a package based on a namespec and a media device */
int
package_extract(Device *dev, char *name, Boolean depended)
@ -107,6 +116,7 @@ package_extract(Device *dev, char *name, Boolean depended)
int i, tot, pfd[2];
pid_t pid;
signal(SIGPIPE, catch_pipe);
msgNotify("Adding %s%s\nfrom %s", path, depended ? " (as a dependency)" : "", dev->name);
pipe(pfd);
pid = fork();
@ -128,7 +138,7 @@ package_extract(Device *dev, char *name, Boolean depended)
tot = 0;
(void)gettimeofday(&start, (struct timezone *)0);
while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) {
while (!sigpipe_caught && (i = fread(buf, 1, BUFSIZ, fp)) > 0) {
int seconds;
if (isDebug())
@ -152,19 +162,20 @@ package_extract(Device *dev, char *name, Boolean depended)
}
close(pfd[1]);
fclose(fp);
if (i == -1)
msgDebug("I/O error while reading in the %s package.\n", name);
if (sigpipe_caught || i == -1)
msgDebug("%s while trying to install the %s package.\n",
sigpipe_caught ? "SIGPIPE" : "I/O error", name);
else
msgInfo("Package %s read successfully - waiting for pkg_add", name);
refresh();
i = waitpid(pid, &tot, 0);
if (i < 0 || WEXITSTATUS(tot)) {
if (sigpipe_caught || i < 0 || WEXITSTATUS(tot)) {
if (variable_get(VAR_NO_CONFIRM))
msgNotify("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
else
msgConfirm("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
}
else
msgNotify("Package %s was added successfully", name);
@ -174,6 +185,7 @@ package_extract(Device *dev, char *name, Boolean depended)
sleep(1);
restorescr(w);
sigpipe_caught = FALSE;
}
}
else {