| Example | Relevant Functions |
8.1 | Effect of fork on buffering and shared variables |
fork
|
8.2 | Effect of vfork on buffering and shared variables |
vfork (old BSD func, no man page)
|
8.3 | Print verbal description of exit status |
sys/wait.h
|
8.4 | Run child processes & print exit statuses |
fork,
exit,
abort,
wait
|
8.5 | Avoid zombie processes by forking twice |
fork,
exit,
waitpid
|
8.6 | Demo of parent/child output race condition |
fork,
setbuf,
putc
|
8.7 | Modification of 8.6
to avoid race condition
Using Stevens' syncronization primitives:
(Similar to Sec. 14.3 but using signals instead of pipes)
Synchronization library primitives:
TELL_WAIT: Init function
TELL_PARENT: Child: notify parent
TELL_CHILD: Parent: notify child
WAIT_PARENT: Child: wait for parent notification
WAIT_CHILD: Parent: wait for child notification
Synchronization library (SunOs),
Synchronization library (4.4BSD),
Synchronization library (SVR4)
| |
8.8 | Exec functions example |
execle,
execlp,
fork,
exit,
waitpid
|
8.9 | Echo command line arguments + environment |
argc, argv, environ (C conventions, no man page)
|
8.10 | Execute an interpreter (sharp/bang) |
fork,
execl,
exit,
waitpid
|
8.11 | Small awk echo-ARGV script as an interpreter file |
|
8.12 | The system function without signal handling |
fork,
execl,
_exit,
waitpid
|
8.13 | Examples of calling system |
system
|
8.14 | Execute the command line argument using system |
argc, argv,
system
|
8.15 | Print real and effective UIDs of a process |
getuid,
geteuid
|
8.16 | Dummy program to generate accounting data |
fork,
execl,
exit,
kill,
sleep
|
8.17 | Print selected field
from system's accounting file (Normally /var/adm/pacct) |
sys/acct.h
|
8.18 | Time & execute all command line arguments |
times,
system,
sysconf (_SC_CLK_TCK)
|