Annotation of coherent/g/usr/lib/uucp/tay104/unix/epopen.c, revision 1.1.1.1

1.1       root        1: /* epopen.c
                      2:    A version of popen that goes through ixsspawn.
                      3: 
                      4:    Copyright (C) 1992 Ian Lance Taylor
                      5: 
                      6:    This file is part of the Taylor UUCP package.
                      7: 
                      8:    This program is free software; you can redistribute it and/or
                      9:    modify it under the terms of the GNU General Public License as
                     10:    published by the Free Software Foundation; either version 2 of the
                     11:    License, or (at your option) any later version.
                     12: 
                     13:    This program is distributed in the hope that it will be useful, but
                     14:    WITHOUT ANY WARRANTY; without even the implied warranty of
                     15:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     16:    General Public License for more details.
                     17: 
                     18:    You should have received a copy of the GNU General Public License
                     19:    along with this program; if not, write to the Free Software
                     20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     21: 
                     22:    The author of the program may be contacted at [email protected] or
                     23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
                     24:    */
                     25: 
                     26: #include "uucp.h"
                     27: 
                     28: #include "sysdep.h"
                     29: 
                     30: #include <errno.h>
                     31: 
                     32: /* A version of popen that goes through ixsspawn.  This actually takes
                     33:    an array of arguments rather than a string, and takes a boolean
                     34:    read/write value rather than a string.  It sets *pipid to the
                     35:    process ID of the child.  */
                     36: 
                     37: FILE *
                     38: espopen (pazargs, frd, pipid)
                     39:      const char **pazargs;
                     40:      boolean frd;
                     41:      pid_t *pipid;
                     42: {
                     43:   int aidescs[3];
                     44:   pid_t ipid;
                     45:   FILE *eret;
                     46: 
                     47:   if (frd)
                     48:     {
                     49:       aidescs[0] = SPAWN_NULL;
                     50:       aidescs[1] = SPAWN_READ_PIPE;
                     51:     }
                     52:   else
                     53:     {
                     54:       aidescs[0] = SPAWN_WRITE_PIPE;
                     55:       aidescs[1] = SPAWN_NULL;
                     56:     }
                     57:   aidescs[2] = SPAWN_NULL;
                     58: 
                     59:   ipid = ixsspawn (pazargs, aidescs, FALSE, FALSE,
                     60:                   (const char *) NULL, FALSE, TRUE,
                     61:                   (const char *) NULL, (const char *) NULL,
                     62:                   (const char *) NULL);
                     63:   if (ipid < 0)
                     64:     return NULL;
                     65: 
                     66:   if (frd)
                     67:     eret = fdopen (aidescs[1], (char *) "r");
                     68:   else
                     69:     eret = fdopen (aidescs[0], (char *) "w");
                     70:   if (eret == NULL)
                     71:     {
                     72:       int ierr;
                     73: 
                     74:       ierr = errno;
                     75:       (void) close (frd ? aidescs[1] : aidescs[0]);
                     76:       (void) kill (ipid, SIGKILL);
                     77:       (void) ixswait ((unsigned long) ipid, (const char *) NULL);
                     78:       errno = ierr;
                     79:       return NULL;
                     80:     }
                     81:     
                     82:   *pipid = ipid;
                     83: 
                     84:   return eret;
                     85: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.