⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 列表6.1.txt

📁 klinux书籍的配套光盘。可以学习学习。
💻 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 + -