Correct exit status checks (status 0 returned by wait() doesn't have to mean
[oweals/dinit.git] / src / service.h
index 27c6a37deefd20a9e2edb9ad79fcd58c09679ca7..eed59e621cb3094e34b33df119fa7c607bc1493f 100644 (file)
 
 struct OnstartFlags {
     bool rw_ready : 1;
+    bool log_ready : 1;
     
     // Not actually "onstart" commands:
     bool no_sigterm : 1;  // do not send SIGTERM
     bool runs_on_console : 1;  // run "in the foreground"
     
-    OnstartFlags() noexcept : rw_ready(false),
+    OnstartFlags() noexcept : rw_ready(false), log_ready(false),
             no_sigterm(false), runs_on_console(false)
     {
     }
@@ -185,7 +186,7 @@ class ServiceChildWatcher : public EventLoop_t::ChildProcWatcher
     public:
     // TODO resolve clunkiness of storing this field
     ServiceRecord * service;
-    void gotTermStat(EventLoop_t * eloop, pid_t child, int status) noexcept;
+    Rearm childStatus(EventLoop_t &eloop, pid_t child, int status) noexcept;
     
     ServiceChildWatcher(ServiceRecord * sr) noexcept : service(sr) { }
 };
@@ -196,14 +197,14 @@ class ServiceIoWatcher : public EventLoop_t::FdWatcher
     // TODO resolve clunkiness of storing these fields
     int fd;
     ServiceRecord * service;
-    Rearm gotEvent(EventLoop_t * eloop, int fd, int flags) noexcept;
+    Rearm fdEvent(EventLoop_t &eloop, int fd, int flags) noexcept;
     
     ServiceIoWatcher(ServiceRecord * sr) noexcept : service(sr) { }
     
-    void registerWith(EventLoop_t *loop, int fd, int flags)
+    void addWatch(EventLoop_t &loop, int fd, int flags)
     {
         this->fd = fd;
-        EventLoop_t::FdWatcher::registerWith(loop, fd, flags);
+        EventLoop_t::FdWatcher::addWatch(loop, fd, flags);
     }
 };
 
@@ -679,6 +680,7 @@ class ServiceSet
     {
         auto prev_tail = console_queue_tail;
         console_queue_tail = newTail;
+        newTail->next_for_console = nullptr;
         if (! prev_tail) {
             console_queue_head = newTail;
             enable_console_log(false);