Blame extension/fork.3am

Packit 575503
.TH FORK 3am "Jan 15 2013" "Free Software Foundation" "GNU Awk Extension Modules"
Packit 575503
.SH NAME
Packit 575503
fork, wait, waitpid \- basic process management
Packit 575503
.SH SYNOPSIS
Packit 575503
.ft CW
Packit 575503
@load "fork"
Packit 575503
.sp
Packit 575503
pid = fork()
Packit 575503
.sp
Packit 575503
ret = waitpid(pid)
Packit 575503
.sp
Packit 575503
ret = wait();
Packit 575503
.ft R
Packit 575503
.SH DESCRIPTION
Packit 575503
The
Packit 575503
.I fork
Packit 575503
extension adds three functions, as follows.
Packit 575503
.TP
Packit 575503
.B fork()
Packit 575503
This function creates a new process. The return value is the zero
Packit 575503
in the child and the process-id number of the child in the parent,
Packit 575503
or \-1 upon error. In the latter case,
Packit 575503
.B ERRNO
Packit 575503
indicates the problem.
Packit 575503
In the child, \fBPROCINFO["pid"]\fP and \fBPROCINFO["ppid"]\fP
Packit 575503
are updated to reflect the correct values.
Packit 575503
.TP
Packit 575503
.B waitpid()
Packit 575503
This function takes a numeric argument, which is the process-id to
Packit 575503
wait for. The return value is that of the
Packit 575503
.IR waitpid (2)
Packit 575503
system call.
Packit 575503
.TP
Packit 575503
.B wait()
Packit 575503
This function waits for the first child to die.
Packit 575503
The return value is that of the
Packit 575503
.IR wait (2)
Packit 575503
system call.
Packit 575503
.\" .SH NOTES
Packit 575503
.SH BUGS
Packit 575503
There is no corresponding
Packit 575503
.B exec()
Packit 575503
function.
Packit 575503
.PP
Packit 575503
The interfaces could be enhanced to provide more facilities,
Packit 575503
including pulling out the various bits of the return status.
Packit 575503
.SH EXAMPLE
Packit 575503
.ft CW
Packit 575503
.nf
Packit 575503
@load "fork"
Packit 575503
\&...
Packit 575503
if ((pid = fork()) == 0)
Packit 575503
    print "hello from the child"
Packit 575503
else
Packit 575503
    print "hello from the parent"
Packit 575503
.fi
Packit 575503
.ft R
Packit 575503
.SH "SEE ALSO"
Packit 575503
.IR "GAWK: Effective AWK Programming" ,
Packit 575503
.IR filefuncs (3am),
Packit 575503
.IR fnmatch (3am),
Packit 575503
.IR inplace (3am),
Packit 575503
.IR ordchr (3am),
Packit 575503
.IR readdir (3am),
Packit 575503
.IR readfile (3am),
Packit 575503
.IR revoutput (3am),
Packit 575503
.IR rwarray (3am),
Packit 575503
.IR time (3am).
Packit 575503
.PP
Packit 575503
.IR fork (2),
Packit 575503
.IR wait (2),
Packit 575503
.IR waitpid (2).
Packit 575503
.SH AUTHOR
Packit 575503
Arnold Robbins,
Packit 575503
.BR arnold@skeeve.com .
Packit 575503
.SH COPYING PERMISSIONS
Packit 575503
Copyright \(co 2012, 2013,
Packit 575503
Free Software Foundation, Inc.
Packit 575503
.PP
Packit 575503
Permission is granted to make and distribute verbatim copies of
Packit 575503
this manual page provided the copyright notice and this permission
Packit 575503
notice are preserved on all copies.
Packit 575503
.ig
Packit 575503
Permission is granted to process this file through troff and print the
Packit 575503
results, provided the printed document carries copying permission
Packit 575503
notice identical to this one except for the removal of this paragraph
Packit 575503
(this paragraph not being relevant to the printed manual page).
Packit 575503
..
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute modified versions of this
Packit 575503
manual page under the conditions for verbatim copying, provided that
Packit 575503
the entire resulting derived work is distributed under the terms of a
Packit 575503
permission notice identical to this one.
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute translations of this
Packit 575503
manual page into another language, under the above conditions for
Packit 575503
modified versions, except that this permission notice may be stated in
Packit 575503
a translation approved by the Foundation.
Packit 575503
.\" vim: set filetype=nroff :