Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fork(2) — GL1 W2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

times(2)

wait(2)

FORK(2)  —  Silicon Graphics

NAME

fork − create a new process

SYNOPSIS

int fork ()

DESCRIPTION

Fork causes creation of a new process.  The new process (child process) is an exact copy of the calling process (parent process).  This means the child process inherits the following attributes from the parent process:

environment

close-on-exec flag (see exec(2))

signal handling settings (i.e., SIG_DFL, SIG_ING, function address)

set-user-ID mode bit

set-group-ID mode bit

profiling on/off status

nice value (see nice(2))

all attached shared memory segments (see shmop(2))

process group ID

tty group ID (see exit(2) and signal(2))

trace flag (see ptrace(2) request 0)

time left until an alarm clock signal (see alarm(2))

current working directory

root directory

file mode creation mask (see umask(2))

file size limit (see ulimit(2))

The child process differs from the parent process in the following ways:

The child process has a unique process ID. 

The child process has a different parent process ID (i.e., the process ID of the parent process). 

The child process has its own copy of the parent’s file descriptors.  Each of the child’s file descriptors shares a common file pointer with the corresponding file descriptor of the parent. 

All semadj values are cleared (see semop(2)).

Process locks, text locks and data locks are not inherited by the child (see plock(2)).

The child process’s utime, stime, cutime, and cstime are set to 0 (see times(2)).

Fork will fail and no child process will be created if one or more of the following are true:

The system-imposed limit on the total number of processes under execution would be exceeded.  ­[EAGAIN]

The system-imposed limit on the total number of processes under execution by a single user would be exceeded.  ­[EAGAIN]

RETURN VALUE

Upon successful completion, fork returns a value of 0 to the child process and returns the process ID of the child process to the parent process.  Otherwise, a value of −1 is returned to the parent process, no child process is created, and errno is set to indicate the error. 

SEE ALSO

exec(2), times(2), wait(2). 

ASSEMBLER

moveq#2,D0
trap#0

New process return. 
Old process return, new process ID in D0. 
Carry bit cleared on success.

The return locations in the old and new process differ by one 16 bit word.  The C-bit is set in the old process if a new process could not be created. 

Version 2.1  —  January 02, 1985

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026