about summary refs log tree commit diff
path: root/src/libutil/util.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-01-19T15·58+0100
committerEelco Dolstra <edolstra@gmail.com>2017-01-19T16·16+0100
commit21948deed99a3295e4d5666e027a6ca42dc00b40 (patch)
tree62579dc51fdee152a67486d428f39ecceb84f08e /src/libutil/util.hh
parent63e10b4d28e64107e51207f292ab0093a95c1bc6 (diff)
Kill builds when we get EOF on the log FD
This closes a long-time bug that allowed builds to hang Nix
indefinitely (regardless of timeouts) simply by doing

  exec > /dev/null 2>&1; while true; do true; done

Now, on EOF, we just send SIGKILL to the child to make sure it's
really gone.
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 67d2891688a2..d00f9c645712 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -192,17 +192,18 @@ typedef std::unique_ptr<DIR, DIRDeleter> AutoCloseDir;
 
 class Pid
 {
-    pid_t pid;
-    bool separatePG;
-    int killSignal;
+    pid_t pid = -1;
+    bool separatePG = false;
+    int killSignal = SIGKILL;
 public:
     Pid();
     Pid(pid_t pid);
     ~Pid();
     void operator =(pid_t pid);
     operator pid_t();
-    void kill(bool quiet = false);
-    int wait(bool block);
+    int kill(bool quiet = false);
+    int wait();
+
     void setSeparatePG(bool separatePG);
     void setKillSignal(int signal);
     pid_t release();