Perl Programming/Keywords/fork

The fork keyword
fork makes a fork(2) call to start the same program at the same point, returning the child PID to its parent process, 0 to the child process, or undef when it was unsuccessful. File descriptors with sometimes their locks are shared, while everything else is copied. Most systems supporting fork implemented it extremely efficient.

Perl attempts to flush all opened files for output before forking the child process, but this may not be supported on some platforms. To be safe, you may need to set $| ($AUTOFLUSH in English) or call the <tt>autoflush</tt> method of <tt>IO::Handle</tt> on all open handles so that duplicate output is avoided.

To <tt>fork</tt> without waiting for the children creates zombies. On some platforms like Windows, the <tt>fork</tt> system call is not available, Perl can be built such that it emulates it in the Perl interpreter.

Examples
returns