Browse Source

Igr: allow reusing igr_proc_watch (and dinit_proc)

Davin McCall 1 month ago
parent
commit
3153c2881c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/igr-tests/igr.h

+ 6 - 1
src/igr-tests/igr.h

@@ -21,7 +21,7 @@ public:
 class igr_proc_watch : public event_loop_t::child_proc_watcher_impl<igr_proc_watch>
 {
 public:
-    bool did_exit = false;
+    bool did_exit = true;
     pid_t child_pid = -1;
     int status = 0;
 
@@ -35,6 +35,11 @@ public:
 
     pid_t fork(event_loop_t &eloop, bool from_reserved = false, int prio = dasynq::DEFAULT_PRIORITY)
     {
+        if (child_pid != -1) {
+            throw std::logic_error("igr_proc_watch: attempted to fork when already watching a process");
+        }
+
+        did_exit = false;
         child_pid = event_loop_t::child_proc_watcher_impl<igr_proc_watch>::fork(eloop, from_reserved, prio);
         return child_pid;
     }