freebsd-dev/contrib/awk/extension/testfork.awk
2001-11-02 21:06:08 +00:00

21 lines
457 B
Awk

BEGIN {
extension("./fork.so", "dlload")
printf "before fork, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
fflush()
ret = fork()
if (ret < 0)
printf("ret = %d, ERRNO = %s\n", ret, ERRNO)
else if (ret == 0)
printf "child, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
else {
system("sleep 3")
printf "parent, ret = %d\n", ret
printf "parent, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
}
}