~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to extension/testfork.awk

  • Committer: Arnold D. Robbins
  • Date: 2010-07-16 10:09:56 UTC
  • Revision ID: git-v1:bc70de7b3302d5a81515b901cae376b8b51d2004
Tags: gawk-3.1.0
Move to gawk-3.1.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
BEGIN {
 
2
        extension("./fork.so", "dlload")
 
3
 
 
4
        printf "before fork, pid = %d, ppid = %d\n", PROCINFO["pid"],
 
5
                        PROCINFO["ppid"]
 
6
 
 
7
        fflush()
 
8
        ret = fork()
 
9
        if (ret < 0)
 
10
                printf("ret = %d, ERRNO = %s\n", ret, ERRNO)
 
11
        else if (ret == 0)
 
12
                printf "child, pid = %d, ppid = %d\n", PROCINFO["pid"],
 
13
                        PROCINFO["ppid"]
 
14
        else {
 
15
                system("sleep 3")
 
16
                printf "parent, ret = %d\n", ret
 
17
                printf "parent, pid = %d, ppid = %d\n", PROCINFO["pid"],
 
18
                        PROCINFO["ppid"]
 
19
        }
 
20
}