~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to extension/testfork.awk

  • Committer: Arnold D. Robbins
  • Date: 2012-11-25 19:54:48 UTC
  • mfrom: (319.1.122)
  • Revision ID: git-v1:9a9ff61bbd952c1263b55f82a269da5b09289a6b
Merge branch 'master' into array-iface

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
 
}