📄 perlfork.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLFORK 1".TH PERLFORK 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlfork \- Perl's fork() emulation.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 4\& NOTE: As of the 5.8.0 release, fork() emulation has considerably\& matured. However, there are still a few known bugs and differences\& from real fork() that might affect you. See the "BUGS" and\& "CAVEATS AND LIMITATIONS" sections below..Ve.PPPerl provides a \fIfork()\fR keyword that corresponds to the Unix system callof the same name. On most Unix-like platforms where the \fIfork()\fR systemcall is available, Perl's \fIfork()\fR simply calls it..PPOn some platforms such as Windows where the \fIfork()\fR system call is notavailable, Perl can be built to emulate \fIfork()\fR at the interpreter level.While the emulation is designed to be as compatible as possible with thereal \fIfork()\fR at the level of the Perl program, there are certainimportant differences that stem from the fact that all the pseudo child\&\*(L"processes\*(R" created this way live in the same real process as far as theoperating system is concerned..PPThis document provides a general overview of the capabilities andlimitations of the \fIfork()\fR emulation. Note that the issues discussed hereare not applicable to platforms where a real \fIfork()\fR is available and Perlhas been configured to use it..SH "DESCRIPTION".IX Header "DESCRIPTION"The \fIfork()\fR emulation is implemented at the level of the Perl interpreter.What this means in general is that running \fIfork()\fR will actually clone therunning interpreter and all its state, and run the cloned interpreter ina separate thread, beginning execution in the new thread just after thepoint where the \fIfork()\fR was called in the parent. We will refer to thethread that implements this child \*(L"process\*(R" as the pseudo-process..PPTo the Perl program that called \fIfork()\fR, all this is designed to betransparent. The parent returns from the \fIfork()\fR with a pseudo-process\&\s-1ID\s0 that can be subsequently used in any process manipulation functions;the child returns from the \fIfork()\fR with a value of \f(CW0\fR to signify thatit is the child pseudo-process..Sh "Behavior of other Perl features in forked pseudo-processes".IX Subsection "Behavior of other Perl features in forked pseudo-processes"Most Perl features behave in a natural way within pseudo-processes..ie n .IP "$$ or $PROCESS_ID" 8.el .IP "$$ or \f(CW$PROCESS_ID\fR" 8.IX Item "$$ or $PROCESS_ID"This special variable is correctly set to the pseudo-process \s-1ID\s0.It can be used to identify pseudo-processes within a particularsession. Note that this value is subject to recycling if anypseudo-processes are launched after others have been \fIwait()\fR\-ed on..ie n .IP "%ENV" 8.el .IP "\f(CW%ENV\fR" 8.IX Item "%ENV"Each pseudo-process maintains its own virtual environment. Modificationsto \f(CW%ENV\fR affect the virtual environment, and are only visible within thatpseudo-process, and in any processes (or pseudo-processes) launched fromit..IP "\fIchdir()\fR and all other builtins that accept filenames" 8.IX Item "chdir() and all other builtins that accept filenames"Each pseudo-process maintains its own virtual idea of the current directory.Modifications to the current directory using \fIchdir()\fR are only visible withinthat pseudo-process, and in any processes (or pseudo-processes) launched fromit. All file and directory accesses from the pseudo-process will correctlymap the virtual working directory to the real working directory appropriately..IP "\fIwait()\fR and \fIwaitpid()\fR" 8.IX Item "wait() and waitpid()"\&\fIwait()\fR and \fIwaitpid()\fR can be passed a pseudo-process \s-1ID\s0 returned by \fIfork()\fR.These calls will properly wait for the termination of the pseudo-processand return its status..IP "\fIkill()\fR" 8.IX Item "kill()"\&\fIkill()\fR can be used to terminate a pseudo-process by passing it the \s-1ID\s0 returnedby \fIfork()\fR. This should not be used except under dire circumstances, becausethe operating system may not guarantee integrity of the process resourceswhen a running thread is terminated. Note that using \fIkill()\fR on apseudo\-\fIprocess()\fR may typically cause memory leaks, because the thread thatimplements the pseudo-process does not get a chance to clean up its resources.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -