summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zoneadm/svc-zones23
-rw-r--r--usr/src/cmd/zoneadmd/zoneadmd.c15
2 files changed, 29 insertions, 9 deletions
diff --git a/usr/src/cmd/zoneadm/svc-zones b/usr/src/cmd/zoneadm/svc-zones
index 295d36c5a5..4b617c0f6e 100644
--- a/usr/src/cmd/zoneadm/svc-zones
+++ b/usr/src/cmd/zoneadm/svc-zones
@@ -3,9 +3,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
# CDDL HEADER END
#
#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# ident "%Z%%M% %I% %E% SMI"
@@ -48,13 +47,19 @@ case "$1" in
ZONES=yes
echo " $zone\c"
#
- # We don't (yet) support restart for zones, so
- # we need to get all of the zones stuff off into
- # a different contract.
+ # zoneadmd puts itself into its own contract so
+ # this service will lose sight of it. We don't
+ # support restart so it is OK for zoneadmd to
+ # to be in an orphaned contract.
#
- ctrun -l none -i none zoneadm -z $zone boot &
+ zoneadm -z $zone boot &
fi
done
+ #
+ # Wait for all zoneadm processes to finish before allowing the
+ # start method to exit.
+ #
+ wait
[ -n "$ZONES" ] && echo .
;;
@@ -101,7 +106,7 @@ case "$1" in
[ ! -z "$WAITPIDS" ] && echo .
# Wait for the 'zoneadm halt' commands to complete. We will let this
- # run forever, since the restart daemon will eventually kill us off
+ # run forever, since the restart daemon will eventually kill us off
# anyway if the halts do not complete after a certain period of time.
wait $WAITPIDS
diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c
index ca6e04e50f..9364735c30 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.c
+++ b/usr/src/cmd/zoneadmd/zoneadmd.c
@@ -1257,6 +1257,8 @@ main(int argc, char *argv[])
zlog_t errlog;
zlog_t *zlogp;
+ int ctfd;
+
progname = get_execbasename(argv[0]);
/*
@@ -1411,12 +1413,25 @@ main(int argc, char *argv[])
(void) sigaddset(&block_cld, SIGCHLD);
(void) sigprocmask(SIG_BLOCK, &block_cld, NULL);
+ if ((ctfd = init_template()) == -1) {
+ zerror(zlogp, B_TRUE, "failed to create contract");
+ return (1);
+ }
+
/*
* Do not let another thread localize a message while we are forking.
*/
(void) mutex_lock(&msglock);
pid = fork();
(void) mutex_unlock(&msglock);
+
+ /*
+ * In all cases (parent, child, and in the event of an error) we
+ * don't want to cause creation of contracts on subsequent fork()s.
+ */
+ (void) ct_tmpl_clear(ctfd);
+ (void) close(ctfd);
+
if (pid == -1) {
zerror(zlogp, B_TRUE, "could not fork");
return (1);