by W. Richard Stevens
Addison-Wesley Professional Computing Series
0-201-56317-7 * Hardcover * 768 pages * ©1992
[Buy this book]
Example | Relevant Functions | |
---|---|---|
14.1 | Send data from parent to child via a pipe | pipe, fork, close, write, read |
14.2 | Display a file by piping into a PAGER program (like more) |
fopen,
pipe,
fork,
close, fgets, strlen, write, ferror, waitpid, dup2, getenv, strrchr, execl |
14.3 | Routines to let a parent and child synchronize: (Similar to Sec. 10.17 but using pipes instead of signals) |
pipe, write, read |
14.4 | Display a file by piping into a PAGER program (Like 14.2 but using popen) |
fopen,
fgets,
fputs,
ferror, popen, pclose |
14.5 | Possible implementation of popen and pclose |
popen : open_max (Stevens' library), calloc, pipe, fork, close, dup2, execl _exit, fdopen pclose : fileno, fclose, waitpid |
14.6 | filter (stdin->stdout) to convert uppercase to lowercase |
getchar,
putchar, isupper, tolower, fflush |
14.7 | Invoke UC->LC filter above to read commands Using popen in read mode |
popen,
fgets,
fputs, fflush, pclose, putchar, err_sys (Stevens' library) |
14.8 | add2: filter (stdin->stdout) example: |
read,
sscanf,
sprintf,
strlen,
write,
exit, err_sys (Stevens' library) |
14.9 | Test driver for 14.8 filter Catching SIGPIPE and acting appropriately. |
signal,
pipe,
fork, close, fgets, strlen, write, read, fputs, ferror, dup2, execl, err_sys (Stevens' library) |
14.10 |
add2: filter to add two numbers (like 14.8) Bad example: wrongly using buffered I/O (stdio). It needs: before the loop to work correctly. |
sscanf,
printf,
fgets, err_sys (Stevens' library) |
14.11 | Shared memory example: Print where different types of data (static array, stack, heap, shared-mem) are stored. |
printf,
malloc, shmget, shmat, shmctl, err_sys (Stevens' library) |
14.12 | IPC between parent & child Using memory mapped I/O of /dev/zero ./dev/zero is used to get a mapped shared memory area initialized to 0.
that parent & child can modify in turn.
|
open,
mmap,
close, fork, exit, TELL_WAIT, TELL_PARENT, TELL_CHILD, WAIT_PARENT, WAIT_CHILD, err_sys, err_quit (Stevens' lib) |