📄 列表6.9.txt
字号:
【列表6.9】摘录自PipeChildMain.pas的程序代码。
const
StrIndexLen = 4;
LF = ^J; { ASCII linefeed/newline }
var
PipeChildMainForm: TPipeChildMainForm;
ParentReadPipe : Integer;
SigActionRec : TSigAction;
implementation
{SR *.xfm}
procedure Handler(Sig : Integer); cdecl;
begin
case Sig of
SIGUSR1 : PipeChildMainForm. ReadPipe;
end; { case }
end;
procedure InstallHandler;
with SigActionRec do
begin
sigaction_handler := Handler;
sigemptyset(sa_mask);
sa_flags :=0;
sigaction(SIGUSR1, @SigActionRec, nil);
end; { with }
end;
procedure TPipeChildMainForm. ReadPipe;
var
ReadBuf : array[0..BUFSIZ] of Char;
s : String;
len : Integer;
begin
{ Get the length of the string }
_read(ParentReadPipe, ReadBuf, StrIndexLen);
ReadBuf[StrIndexLen] := chr(0);
len := StrToInt(ReadBuf);
{ Get the string }
read(ParentReadPipe, ReadBuf, len);
ReadBuf[len] := chr(0);
s := ReadBuf;
MsgMemo,Lines.Add(s);
end;
procedure TPipeChildMainForm. FormCreate(Sender: TObject);
begin
InstallHandler;
ParentReadPipe := StrToInt(ParamStr(1));
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -