1FORK(3am)                  GNU Awk Extension Modules                 FORK(3am)
2
3
4

NAME

6       fork, wait, waitpid - basic process management
7

SYNOPSIS

9       @load "fork"
10
11       pid = fork()
12
13       ret = waitpid(pid)
14
15       ret = wait();
16

DESCRIPTION

18       The fork extension adds three functions, as follows.
19
20       fork() This  function  creates  a  new process. The return value is the
21              zero in the child and the process-id number of the child in  the
22              parent,  or  -1  upon error. In the latter case, ERRNO indicates
23              the problem.  In the child, PROCINFO["pid"] and PROCINFO["ppid"]
24              are updated to reflect the correct values.
25
26       waitpid()
27              This  function takes a numeric argument, which is the process-id
28              to wait for. The return value is that of the  waitpid(2)  system
29              call.
30
31       wait() This  function  waits  for  the  first child to die.  The return
32              value is that of the wait(2) system call.
33

BUGS

35       There is no corresponding exec() function.
36
37       The interfaces could be enhanced to provide more facilities,  including
38       pulling out the various bits of the return status.
39

EXAMPLE

41       @load "fork"
42       ...
43       if ((pid = fork()) == 0)
44           print "hello from the child"
45       else
46           print "hello from the parent"
47

SEE ALSO

49       GAWK:   Effective   AWK   Programming,   filefuncs(3am),  fnmatch(3am),
50       inplace(3am), ordchr(3am), readdir(3am), readfile(3am), revoutput(3am),
51       rwarray(3am), time(3am).
52
53       fork(2), wait(2), waitpid(2).
54

AUTHOR

56       Arnold Robbins, arnold@skeeve.com.
57

COPYING PERMISSIONS

59       Copyright © 2012, 2013, Free Software Foundation, Inc.
60
61       Permission  is  granted  to make and distribute verbatim copies of this
62       manual page provided the copyright notice and  this  permission  notice
63       are preserved on all copies.
64
65       Permission  is granted to copy and distribute modified versions of this
66       manual page under the conditions for verbatim  copying,  provided  that
67       the  entire  resulting derived work is distributed under the terms of a
68       permission notice identical to this one.
69
70       Permission is granted to copy and distribute translations of this  man‐
71       ual page into another language, under the above conditions for modified
72       versions, except that this permission notice may be stated in a  trans‐
73       lation approved by the Foundation.
74
75
76
77Free Software Foundation          Jan 15 2013                        FORK(3am)
Impressum