]> git.mdlowis.com Git - projs/tide.git/commitdiff
only provide a callback for command I/O if the pipe direction is being used.
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 8 May 2018 18:41:37 +0000 (14:41 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 8 May 2018 18:41:37 +0000 (14:41 -0400)
lib/job.c

index e9c345984f7a863430b4f56fd546e3292569954b..2cdc56a52849850e8df827ed4d123dc7c183e362 100644 (file)
--- a/lib/job.c
+++ b/lib/job.c
@@ -132,7 +132,7 @@ void job_spawn(int fd, jobfn_t readfn, jobfn_t writefn, void* data) {
 
 void job_start(char** cmd, char* data, size_t ndata, View* dest) {
     int fd = job_exec(cmd);
-    if (fd >= 0) {
+    if (fd >= 0 && (data || dest)) {
         struct PipeData* pipedata = NULL;
         if (data) {
             pipedata = calloc(1, sizeof(struct PipeData));
@@ -140,6 +140,8 @@ void job_start(char** cmd, char* data, size_t ndata, View* dest) {
             pipedata->ndata = ndata;
             pipedata->dest = dest;
         }
-        job_spawn(fd, pipe_read, pipe_write, pipedata);
+        job_spawn(fd, (data ? pipe_read : NULL), (dest ? pipe_write : NULL), pipedata);
+    } else {
+        close(fd);
     }
 }