/[man-db]/man-db/lib/pipeline.c
ViewVC logotype

Diff of /man-db/lib/pipeline.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by cjwatson, Sun Aug 3 23:00:23 2003 UTC revision 1.10 by cjwatson, Sun Aug 3 23:32:47 2003 UTC
# Line 290  pipeline *pipeline_new (void) Line 290  pipeline *pipeline_new (void)
290          p->pids = NULL;          p->pids = NULL;
291          p->want_in = p->want_out = 0;          p->want_in = p->want_out = 0;
292          p->infd = p->outfd = -1;          p->infd = p->outfd = -1;
293            p->infile = p->outfile = NULL;
294          return p;          return p;
295  }  }
296    
# Line 329  pipeline *pipeline_join (pipeline *p1, p Line 330  pipeline *pipeline_join (pipeline *p1, p
330          p->want_out = p2->want_out;          p->want_out = p2->want_out;
331          p->infd = p1->infd;          p->infd = p1->infd;
332          p->outfd = p2->outfd;          p->outfd = p2->outfd;
333            p->infile = p1->infile;
334            p->outfile = p2->outfile;
335    
336          for (i = 0; i < p1->ncommands; ++i)          for (i = 0; i < p1->ncommands; ++i)
337                  p->commands[i] = command_dup (p1->commands[i]);                  p->commands[i] = command_dup (p1->commands[i]);
# Line 384  void pipeline_commands (pipeline *p, ... Line 387  void pipeline_commands (pipeline *p, ...
387          va_end (cmdv);          va_end (cmdv);
388  }  }
389    
390    FILE *pipeline_get_infile (pipeline *p)
391    {
392            assert (p->pids);       /* pipeline started */
393            if (p->infile)
394                    return p->infile;
395            else if (p->infd == -1) {
396                    error (0, 0, _("pipeline input not open"));
397                    return NULL;
398            } else
399                    return p->infile = fdopen (p->infd, "w");
400    }
401    
402    FILE *pipeline_get_outfile (pipeline *p)
403    {
404            assert (p->pids);       /* pipeline started */
405            if (p->outfile)
406                    return p->outfile;
407            else if (p->outfd == -1) {
408                    error (0, 0, _("pipeline output not open"));
409                    return NULL;
410            } else
411                    return p->outfile = fdopen (p->outfd, "r");
412    }
413    
414  /* Children exit with this status if execvp fails. */  /* Children exit with this status if execvp fails. */
415  #define EXEC_FAILED_EXIT_STATUS 0xff  #define EXEC_FAILED_EXIT_STATUS 0xff
416    
# Line 510  int pipeline_wait (pipeline *p) Line 537  int pipeline_wait (pipeline *p)
537    
538          assert (p->pids);       /* pipeline started */          assert (p->pids);       /* pipeline started */
539    
540          if (p->infd != -1) {          if (p->infile) {
541                  close (p->infd);                  if (fclose (p->infile))
542                            error (0, errno,
543                                   _("closing pipeline input stream failed"));
544                    p->infile = NULL;
545                    p->infd = -1;
546            } else if (p->infd != -1) {
547                    if (close (p->infd))
548                            error (0, errno, _("closing pipeline input failed"));
549                  p->infd = -1;                  p->infd = -1;
550          }          }
551    
# Line 556  int pipeline_wait (pipeline *p) Line 590  int pipeline_wait (pipeline *p)
590                          }                          }
591          }          }
592    
593          if (p->outfd != -1) {          if (p->outfile) {
594                  close (p->outfd);                  if (fclose (p->outfile))
595                            error (0, errno,
596                                   _("closing pipeline output stream failed"));
597                    p->outfile = NULL;
598                    p->outfd = -1;
599            } else if (p->outfd != -1) {
600                    if (close (p->outfd))
601                            error (0, errno, _("closing pipeline output failed"));
602                  p->outfd = -1;                  p->outfd = -1;
603          }          }
604    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26