?? 列表5.3.txt
字號:
【列表5.3】使用函數fork建立一個子進程。
{forkTest.dpr - Illustrate using fork to create a child process }
program forkTest;
{$APPTYPE CONSOLE}
uses Libc, SysUtils;
var
forkResult : __pid_t;
procedure DoChildProcess;
begin
WriteLn ('Child: ProcessID = ', getpid);
sleep (10);
WriteLn ('Child: Exiting');
end;
procedure DoParentProcess;
begin
WriteLn ('Parent: Child ProcessID = ', forkResult);
sleep (5);
WriteLn ('Parent: Exiting');
end;
begin
WriteLn ('Parent: ProcessID = ', getpid);
forkResult := fork;
case forkResult of
-1 : WriteLn ('Error creating child process');
0 : DoChildProcess;
else
DoParentProcess;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -