|
| 1 | +NAME |
| 2 | + pfe - pipe/fork/exec and friends |
| 3 | + |
| 4 | +SYNOPSIS |
| 5 | + pipe = custom("pipe") ## create descriptor pair for interprocess communication |
| 6 | + pid = custom("fork") ## create process |
| 7 | + tgt = custom("dup", src) ## duplicate a file descriptor |
| 8 | + tgt = custom("dup2", src, tgt) ## duplicate a file descriptor |
| 9 | + e = custom("close", fd) ## remove a file descriptor |
| 10 | + e = custom("execvp", arg0, args) ## execute a file |
| 11 | + count = custom("write", fd, str) ## write output |
| 12 | + str = custom("read", fd) ## read input |
| 13 | + count = custom("select", rd, wt, exc[, timeout]) ## examine file descriptors |
| 14 | + count = custom("poll", chk, &ret[, msecs]) ## synchronous I/O multiplexing |
| 15 | + pid = custom("wait", [pid, ]&stt[, opts][, &usg]) ## wait for process |
| 16 | + |
| 17 | + pid = custom("pfe", &in, &out, &err, args) ## pipe/fork/exec |
| 18 | + count = custom("pwrite", fd, str) ## write and close |
| 19 | + e = custom("pread", pid, out, err) ## read until eof, close and wait for exit status |
| 20 | + |
| 21 | + str = custom("inputname") ## get name of input |
| 22 | + path = custom("getcwd") ## get working directory pathname |
| 23 | + |
| 24 | + path = custom("basename", path) ## extract the base portion of a pathname |
| 25 | + path = custom("dirname", path) ## extract the directory part of a pathname |
| 26 | + |
| 27 | + pid = custom("getpid") ## get calling process identification |
| 28 | + pid = custom("getppid") ## get parent process identification |
| 29 | + |
| 30 | +TYPES |
| 31 | + fd int num |
| 32 | + pipe list of fd |
| 33 | + pid int num |
| 34 | + src tgt fd |
| 35 | + arg0 str |
| 36 | + args list of str |
| 37 | + e int num |
| 38 | + count int num |
| 39 | + rd wt exc list of fd |
| 40 | + in out err list of fd |
| 41 | + timeout num |
| 42 | + |
| 43 | + arg1 str |
| 44 | + ...argN str |
| 45 | + chk list of list(fd[, arg1[, ...argN]]) |
| 46 | + ret list of list(fd[, arg1[, ...argN]]) |
| 47 | + msec int num |
| 48 | + |
| 49 | + stt assoc str => int num |
| 50 | + opts list of str |
| 51 | + usg assoc str => int num |
| 52 | + |
| 53 | + path str |
| 54 | + |
| 55 | +EXAMPLE |
| 56 | + global i, o, e |
| 57 | + if(pid = pfe(&i, &o, &e,list("sh","-c","read||:;echo $REPLY"))){ |
| 58 | + pwrite(i,"test") |
| 59 | + pread(pid,o,e)} |
| 60 | + |
| 61 | +LIMITS |
| 62 | + calc must be built with ALLOW_CUSTOM= -DCUSTOM |
| 63 | + calc must be executed with a -C arg. |
| 64 | + |
| 65 | +LIBRARY |
| 66 | + none |
| 67 | + |
| 68 | +SEE ALSO |
| 69 | + custom |
| 70 | + |
| 71 | +## Copyright (C) 2024 Viktor Bergquist |
| 72 | +## |
| 73 | +## Calc is open software; you can redistribute it and/or modify it under |
| 74 | +## the terms of the version 2.1 of the GNU Lesser General Public License |
| 75 | +## as published by the Free Software Foundation. |
| 76 | +## |
| 77 | +## Calc is distributed in the hope that it will be useful, but WITHOUT |
| 78 | +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 79 | +## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General |
| 80 | +## Public License for more details. |
| 81 | +## |
| 82 | +## A copy of version 2.1 of the GNU Lesser General Public License is |
| 83 | +## distributed with calc under the filename COPYING-LGPL. You should have |
| 84 | +## received a copy with calc; if not, write to Free Software Foundation, Inc. |
| 85 | +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 86 | +## |
| 87 | +## Under source code control: 1997/03/09 20:28:01 |
| 88 | +## File existed as early as: 1997 |
| 89 | +## |
| 90 | +## chongo <was here> /\oo/\ http://www.isthe.com/chongo/ |
| 91 | +## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ |
0 commit comments