skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

child_spawn1_pipe.c (384B)


      1 /* ISC license. */
      2 
      3 #include <unistd.h>
      4 
      5 #include <skalibs/cspawn.h>
      6 #include "cspawn-internal.h"
      7 
      8 pid_t child_spawn1_pipe (char const *prog, char const *const *argv, char const *const *envp, int *fd, int to)
      9 {
     10   pid_t pid ;
     11   int p[2] ;
     12   if (pipe(p) < 0) return 0 ;
     13   pid = child_spawn1_internal(prog, argv, envp, p, !!to) ;
     14   if (!pid) return 0 ;
     15   *fd = p[!to] ;
     16   return pid ;
     17 }