summaryrefslogtreecommitdiff
path: root/usr/src/cmd/svc
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2013-10-25 20:31:36 +0000
committerRobert Mustacchi <rm@joyent.com>2014-08-20 15:24:37 -0700
commitac0324d26eb303fa7f174e9ed0543767cca4ad95 (patch)
tree1d5198ff5fa5724d4075e688b38f984aef9bf696 /usr/src/cmd/svc
parent37b40227c992afc6bf6acdd1854ccd2e42a45028 (diff)
downloadillumos-gate-ac0324d26eb303fa7f174e9ed0543767cca4ad95.tar.gz
5024 Want svcadm restart -d [...] for taking cores before restart
Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Albert Lee <trisk@nexenta.com> Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src/cmd/svc')
-rw-r--r--usr/src/cmd/svc/startd/restarter.c26
-rw-r--r--usr/src/cmd/svc/svcadm/svcadm.c25
2 files changed, 48 insertions, 3 deletions
diff --git a/usr/src/cmd/svc/startd/restarter.c b/usr/src/cmd/svc/startd/restarter.c
index 6adb323289..53271ab039 100644
--- a/usr/src/cmd/svc/startd/restarter.c
+++ b/usr/src/cmd/svc/startd/restarter.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
/*
@@ -1572,6 +1572,22 @@ event_from_tty(scf_handle_t *h, restarter_inst_t *rip)
return (ret);
}
+static boolean_t
+restart_dump(scf_handle_t *h, restarter_inst_t *rip)
+{
+ scf_instance_t *inst;
+ boolean_t ret = B_FALSE;
+
+ if (libscf_fmri_get_instance(h, rip->ri_i.i_fmri, &inst))
+ return (-1);
+
+ if (restarter_inst_dump(inst) == 1)
+ ret = B_TRUE;
+
+ scf_instance_destroy(inst);
+ return (ret);
+}
+
static void
maintain_instance(scf_handle_t *h, restarter_inst_t *rip, int immediate,
restarter_str_t reason)
@@ -1865,8 +1881,14 @@ again:
* Stop the instance. If it can be restarted,
* the graph engine will send a new event.
*/
- if (stop_instance(h, inst, RSTOP_RESTART) == 0)
+ if (restart_dump(h, inst)) {
+ (void) contract_kill(
+ inst->ri_i.i_primary_ctid, SIGABRT,
+ inst->ri_i.i_fmri);
+ } else if (stop_instance(h, inst,
+ RSTOP_RESTART) == 0) {
reset_start_times(inst);
+ }
}
break;
diff --git a/usr/src/cmd/svc/svcadm/svcadm.c b/usr/src/cmd/svc/svcadm/svcadm.c
index 0c69b4a194..7cd61454c9 100644
--- a/usr/src/cmd/svc/svcadm/svcadm.c
+++ b/usr/src/cmd/svc/svcadm/svcadm.c
@@ -155,7 +155,7 @@ usage()
"\t%1$s enable [-rst] [<service> ...]\t- enable and online service(s)\n"
"\t%1$s disable [-st] [<service> ...]\t- disable and offline "
"service(s)\n"
- "\t%1$s restart [<service> ...]\t\t- restart specified service(s)\n"
+ "\t%1$s restart [-d] [<service> ...]\t- restart specified service(s)\n"
"\t%1$s refresh [<service> ...]\t\t- re-read service configuration\n"
"\t%1$s mark [-It] <state> [<service> ...] - set maintenance state\n"
"\t%1$s clear [<service> ...]\t\t- clear maintenance state\n"
@@ -2431,7 +2431,20 @@ again:
exit_status = error;
} else if (strcmp(argv[optind], "restart") == 0) {
+ boolean_t do_dump = B_FALSE;
+
++optind;
+
+ while ((o = getopt(argc, argv, "d")) != -1) {
+ if (o == 'd')
+ do_dump = B_TRUE;
+ else if (o == '?')
+ usage();
+ else {
+ assert(0);
+ abort();
+ }
+ }
argc -= optind;
argv += optind;
@@ -2441,6 +2454,16 @@ again:
if (argc > 0 && svcsearch)
usage();
+ if (do_dump) {
+ if ((err = scf_walk_fmri(h, argc, argv, WALK_FLAGS,
+ set_fmri_action, (void *)SCF_PROPERTY_DODUMP,
+ &exit_status, pr_warn)) != 0) {
+ pr_warn(gettext("failed to iterate over "
+ "instances: %s\n"), scf_strerror(err));
+ exit_status = UU_EXIT_FATAL;
+ }
+ }
+
if ((err = scf_walk_fmri(h, argc, argv, WALK_FLAGS,
set_fmri_action, (void *)SCF_PROPERTY_RESTART, &exit_status,
pr_warn)) != 0) {