summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/halt/halt.c78
1 files changed, 33 insertions, 45 deletions
diff --git a/usr/src/cmd/halt/halt.c b/usr/src/cmd/halt/halt.c
index 053067fe9f..bafce88e5b 100644
--- a/usr/src/cmd/halt/halt.c
+++ b/usr/src/cmd/halt/halt.c
@@ -1129,6 +1129,35 @@ parse_fastboot_args(char *bootargs_buf, int *is_dryrun, const char *bename,
return (rc);
}
+#define MAXARGS 5
+
+static void
+do_archives_update(int do_fast_reboot)
+{
+ int r, i = 0;
+ pid_t pid;
+ char *cmd_argv[MAXARGS];
+
+
+ cmd_argv[i++] = "/sbin/bootadm";
+ cmd_argv[i++] = "-ea";
+ cmd_argv[i++] = "update_all";
+ if (do_fast_reboot)
+ cmd_argv[i++] = "fastboot";
+ cmd_argv[i] = NULL;
+
+ r = posix_spawn(&pid, cmd_argv[0], NULL, NULL, cmd_argv, NULL);
+
+ /* if posix_spawn fails we emit a warning and continue */
+
+ if (r != 0)
+ (void) fprintf(stderr, gettext("%s: WARNING, unable to start "
+ "boot archive update\n"), cmdname);
+ else
+ while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
+ ;
+}
+
int
main(int argc, char *argv[])
{
@@ -1368,26 +1397,8 @@ main(int argc, char *argv[])
/* if we're dumping, do the archive update here and don't defer it */
- if (cmd == A_DUMP && zoneid == GLOBAL_ZONEID && !nosync) {
- char *fast_argv[] = {"/sbin/bootadm", "-ea", "update_all",
- "fastboot", NULL};
- char *b_argv[] = {"/sbin/bootadm", "-ea", "update_all", NULL};
-
- if (fast_reboot)
- r = posix_spawn(NULL, fast_argv[0], NULL, NULL,
- fast_argv, NULL);
- else
- r = posix_spawn(NULL, b_argv[0], NULL, NULL, b_argv,
- NULL);
-
- /* if posix_spawn fails we emit a warning and continue */
-
- if (r != 0)
- (void) fprintf(stderr, gettext("%s: WARNING, unable to"
- " start boot archive update\n"), cmdname);
- else
- (void) wait(NULL);
- }
+ if (cmd == A_DUMP && zoneid == GLOBAL_ZONEID && !nosync)
+ do_archives_update(fast_reboot);
/*
* If we're not forcing a crash dump, mark the system as quiescing for
@@ -1447,31 +1458,8 @@ main(int argc, char *argv[])
(void) kill(-1, SIGTERM);
start = time(NULL);
- if (zoneid == GLOBAL_ZONEID && !nosync) {
- char *fast_argv[] = {"/sbin/bootadm", "-ea",
- "update_all", "fastboot", NULL};
- char *b_argv[] = {"/sbin/bootadm", "-ea", "update_all",
- NULL};
-
- if (fast_reboot)
- r = posix_spawn(NULL, fast_argv[0], NULL, NULL,
- fast_argv, NULL);
- else
- r = posix_spawn(NULL, b_argv[0], NULL, NULL,
- b_argv, NULL);
-
- /*
- * if posix_spawn fails we emit a warning and
- * continue
- */
-
- if (r != 0)
- (void) fprintf(stderr, gettext("%s: WARNING, "
- "unable to start boot archive update\n"),
- cmdname);
- else
- (void) wait(NULL);
- }
+ if (zoneid == GLOBAL_ZONEID && !nosync)
+ do_archives_update(fast_reboot);
end = time(NULL);
delta = end - start;