man > fork(3am)

๐Ÿ“š NAME

fork, wait, waitpid โ€“ ๐Ÿงต basic process management

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ‘ถ Create a child processfork()Returns 0 in child, PID in parent, or -1 on error
โณ Wait for a specific childwaitpid(pid)Waits for process with given PID to finish
โณ Wait for any childwait()Waits for the first child process to terminate

๐Ÿ“– SYNOPSIS

@load "fork"

pid = fork()

ret = waitpid(pid)

ret = wait();

๐Ÿ“ DESCRIPTION

The fork extension adds three functions, as follows.

๐Ÿ”ง fork()

This function creates a new process. The return value is zero in the child and the process-id number of the child in the parent, or -1 upon error. In the latter case, ERRNO indicates the problem. In the child, PROCINFO["pid"] and PROCINFO["ppid"] are updated to reflect the correct values.

๐Ÿ”ง waitpid()

This function takes a numeric argument, which is the process-id to wait for. The return value is that of the waitpid(2) system call.

๐Ÿ”ง wait()

This function waits for the first child to die. The return value is that of the wait(2) system call.

๐Ÿ› BUGS

๐Ÿ’ก EXAMPLE

@load "fork"
...
if ((pid = fork()) == 0)
    print "hello from the child"
else
    print "hello from the parent"

๐Ÿ“š SEE ALSO

โœ๏ธ AUTHOR

Arnold Robbins, arnold@skeeve.com.

๐Ÿ“„ COPYING PERMISSIONS

Copyright ยฉ 2012, 2013, 2018, Free Software Foundation, Inc.

Free Software Foundation ยท Feb 02 2018 ยท FORK(3am)

fork(3am)
๐Ÿ“š NAME ๐Ÿš€ Quick Reference ๐Ÿ“– SYNOPSIS ๐Ÿ“ DESCRIPTION
๐Ÿ”ง fork() ๐Ÿ”ง waitpid() ๐Ÿ”ง wait()
๐Ÿ› BUGS ๐Ÿ’ก EXAMPLE ๐Ÿ“š SEE ALSO โœ๏ธ AUTHOR ๐Ÿ“„ COPYING PERMISSIONS

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-15 19:28 @216.73.216.233
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!