Print this page
Extra lint fixes
OS-5642 containerbuddy unable to fork while using syslog driver, causing container services to hang
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Patrick Mooney <patrick.mooney@joyent.com>
OS-4781 would like to be able to add CT_PR_EV_EXIT to fatal event set of current contract

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2016 Joyent, Inc.
  */
 
 #include <sys/mutex.h>
 #include <sys/debug.h>
 #include <sys/types.h>

@@ -953,10 +954,22 @@
                 event->cte_flags = EVINFOP(ctp, CT_PR_EV_EXIT) ? CTE_INFO : 0;
                 event->cte_type = CT_PR_EV_EXIT;
                 (void) cte_publish_all(ct, event, nvl, NULL);
                 mutex_enter(&ct->ct_lock);
         }
+
+        /*
+         * CT_PR_EV_EXIT is not part of the CT_PR_ALLFATAL definition since
+         * we never allow including this in the fatal set via a user-land
+         * application, but we do allow CT_PR_EV_EXIT in the contract's fatal
+         * set for a process setup for zone init. See zone_start_init().
+         */
+        if (EVFATALP(ctp, CT_PR_EV_EXIT)) {
+                ASSERT(MUTEX_HELD(&ct->ct_lock));
+                contract_process_kill(ct, p, B_TRUE);
+        }
+
         if (empty) {
                 /*
                  * Send EMPTY message.
                  */
                 if (EVSENDP(ctp, CT_PR_EV_EMPTY)) {

@@ -1055,10 +1068,21 @@
                 event = kmem_zalloc(sizeof (ct_kevent_t), KM_SLEEP);
                 event->cte_flags = EVINFOP(ctp, CT_PR_EV_FORK) ? CTE_INFO : 0;
                 event->cte_type = CT_PR_EV_FORK;
                 (void) cte_publish_all(ct, event, nvl, NULL);
         }
+
+        /*
+         * Because the CT_PR_KEEP_EXEC flag is meant to be used by applications
+         * which are not contract aware, we can assume that these applications
+         * will never explicitly abandon the child's new contract. Thus, we
+         * abandon it now.
+         */
+        if (ctp->conp_params & CT_PR_KEEP_EXEC) {
+                (void) contract_abandon(ct, pp, 1);
+        }
+
         return (ctp);
 }
 
 /*
  * contract_process_core