NAME
    pfe - pipe/fork/exec and friends

SYNOPSIS
    pipe    = custom("pipe")                                ## create descriptor pair for interprocess communication
    pid     = custom("fork")                                ## create process
    tgt     = custom("dup", src)                            ## duplicate a file descriptor
    tgt     = custom("dup2", src, tgt)                      ## duplicate a file descriptor
    e       = custom("close", fd)                           ## remove a file descriptor
    e       = custom("execvp", arg0, args)                  ## execute a file
    count   = custom("write", fd, str)                      ## write output
    str     = custom("read", fd)                            ## read input
    count   = custom("select", rd, wt, exc[, timeout])      ## examine file descriptors
    count   = custom("poll", chk, &ret[, msecs])            ## synchronous I/O multiplexing
    pid     = custom("wait", [pid, ]&stt[, opts][, &usg])   ## wait for process

    pid     = custom("pfe", &in, &out, &err, args)          ## pipe/fork/exec
    count   = custom("pwrite", fd, str)                     ## write and close
    e       = custom("pread", pid, out, err)                ## read until eof, close and wait for exit status

    str     = custom("inputname")                           ## get name of input
    path    = custom("getcwd")                              ## get working directory pathname

    path    = custom("basename", path)                      ## extract the base portion of a pathname
    path    = custom("dirname", path)                       ## extract the directory part of a pathname

    pid     = custom("getpid")                              ## get calling process identification
    pid     = custom("getppid")                             ## get parent process identification

TYPES
    fd          int num
    pipe        list of fd
    pid         int num
    src tgt     fd
    arg0        str
    args        list of str
    e           int num
    count       int num
    rd wt exc   list of fd
    in out err  list of fd
    timeout     num

    arg1        str
    ...argN     str
    chk         list of list(fd[, arg1[, ...argN]])
    ret         list of list(fd[, arg1[, ...argN]])
    msec        int num

    stt         assoc str => int num
    opts        list of str
    usg         assoc str => int num

    path        str

EXAMPLE
    global i, o, e
    if(pid = pfe(&i, &o, &e,list("sh","-c","read||:;echo $REPLY"))){
        pwrite(i,"test")
        pread(pid,o,e)}

LIMITS
    calc must be built with ALLOW_CUSTOM= -DCUSTOM
    calc must be executed with a -C arg.

LIBRARY
    none

SEE ALSO
    custom

## Copyright (C) 2024 Viktor Bergquist
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL.  You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
