]> granicus.if.org Git - pdns/commitdiff
pipebackend coprocess: initialise d_pid
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 20 Sep 2019 08:03:30 +0000 (10:03 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 20 Sep 2019 08:03:30 +0000 (10:03 +0200)
modules/pipebackend/coprocess.cc

index 2da3dacd7ed896dc532972a767b8e52bba30d0ca..419b53a83c285910323d03ab5a30d3e9cc49e8b3 100644 (file)
@@ -50,6 +50,7 @@ CoProcess::CoProcess(const string &command,int timeout, int infd, int outfd): d_
   for (size_t n = 0; n < d_params.size(); n++) {
     d_argv[n]=d_params[n].c_str();
   }
+  d_pid = 0;
 }
 
 void CoProcess::launch()
@@ -103,9 +104,11 @@ void CoProcess::launch()
 CoProcess::~CoProcess()
 {
   int status;
-  if(!waitpid(d_pid, &status, WNOHANG)) {
-    kill(d_pid, 9);
-    waitpid(d_pid, &status, 0);
+  if(d_pid){
+    if(!waitpid(d_pid, &status, WNOHANG)) {
+      kill(d_pid, 9);
+      waitpid(d_pid, &status, 0);
+    }
   }
   
   close(d_fd1[1]);