?? 列表6.1.txt
字號:
【列表6.1】 摘錄來自SigSendMain.pas的代碼。
procedure TSigSendMainForm. SendBtnClick(Sender: TObject);
var
i : Integer;
ErrResult : Integer;
SigValue : Integer;
L : TList;
PRec : PProcInfoRec;
begin
ErrResult := 0;
SigValue := -1;
{ Determine the signal value to send }
case SigRBGroup. ItemIndex of
0 : SigValue := StGINT;
1: SigValue := SIGCHLD;
2 : SigValue := SIGUSR1;
end; { case }
{ Get the CTD process info if executing }
L := GetProcessListByName('CrashTestDummy');
if L.Count > 0
then for i := 0 to L.Count - 1 do
begin
PRec := L.Items[i];
with PRec^ do
begin
if MessageDlg('Sending Signal'.
'Process ' + IntToStr(i + 1) + ' of ' + IntToStr(L.Count)
+ LF + LF
+ 'Send to this process?' + LF + LF
+ 'Process ID: ' + IntToStr(PID) + LF,
mtConfirmation, [mbYes, mbNo], 0) = mrYes
then ErrResult := kill(PID, SigValue);
if ErrResult <> 0
then MessageDlg('Error', 'Unable to perform this '
+ 'operation!', mtError, [mbOK], 0);
end; { with }
end { for }
else MessageDlg('Error', 'CrashTestDummy not running',
mtError, [mbOK], 0);
L.Free;
end;
procedure TSigSendMainForm. ShutdownXBtnClick(Sender: TObject);
var
L : TList;
PRec : PProcInfoRec;
ErrResult : Integer;
begin
ErrResult :=0;
if (getuid =0) { root }
then begin
MessageDlg('Error', 'We told you not to run this as "root"'
mtError, [mbOK], 0);
Exit;
end;
{ Get the X Window process info }
L := GetProcessListByName('X');
if L.Count > 0
then begin
PRec := L.Items[0];
with PRec^ do
begin
if MessageDlg('Sending Signal',
'Send to this process?' + LF + LF
+ 'Process ID: ' + IntToStr(PID) + LF,
mtConfirmation, [mbYes, mbNo], 0 ) - mrYes
then ErrResult := kill(PID, SIGTERM);
if ErrResult <> 0
then MessageDlg('Error', 'Not allowed to perform this '
+ 'operation!', mtError, [mbOK], 0);
end; { with }
end
else MessageDlg('Error', 'X Windows not running',
mtError, [mbOK], 0);
L.Free;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -