Record shutdown type (halt, poweroff, reboot) in the service set.
authorDavin McCall <davmac@davmac.org>
Wed, 30 Dec 2015 22:18:14 +0000 (22:18 +0000)
committerDavin McCall <davmac@davmac.org>
Wed, 30 Dec 2015 22:18:14 +0000 (22:18 +0000)
service-constants.h
service.h

index 083610684533001f6bd3a3c7643b62532fe7ecea..f54720ba4a88214fa70df2dad2bf005995b76b71 100644 (file)
@@ -28,5 +28,12 @@ enum class ServiceEvent {
     STOPCANCELLED      // Service was set to be stopped but a start was requested
 };
 
+/* Shutdown types */
+enum class ShutdownType {
+    CONTINUE,          // Continue normal boot sequence (used after single-user shell)
+    HALT,              // Halt system without powering down
+    POWEROFF,          // Power off system
+    REBOOT             // Reboot system
+};
 
 #endif
index 5f533f5d00f2791c2c9d217048c15a79b9c32090..e9809fc639f644aec6342320f999bd010ecfbd33 100644 (file)
--- a/service.h
+++ b/service.h
@@ -364,6 +364,8 @@ class ServiceSet
     bool restart_enabled; // whether automatic restart is enabled (allowed)
     ControlConn *rollback_handler; // recieves notification when all services stopped
     
+    ShutdownType shutdown_type = ShutdownType::CONTINUE;  // Shutdown type, if stopping
+    
     // Private methods
         
     // Load a service description, and dependencies, if there is no existing
@@ -426,9 +428,10 @@ class ServiceSet
         return active_services;
     }
     
-    void stop_all_services() noexcept
+    void stop_all_services(ShutdownType type = ShutdownType::HALT) noexcept
     {
         restart_enabled = false;
+        shutdown_type = type;
         for (std::list<ServiceRecord *>::iterator i = records.begin(); i != records.end(); ++i) {
             (*i)->stop();
         }
@@ -444,6 +447,11 @@ class ServiceSet
         return restart_enabled;
     }
     
+    ShutdownType getShutdownType() noexcept
+    {
+        return shutdown_type;
+    }
+    
     // Set the rollback handler, which will be notified when all services have stopped.
     // There can be only one rollback handler; attempts to set it when already set will
     // fail. Returns true if successful.