Преглед на файлове

+ Added 64,65, fixed sigactionrec to new definition

michael преди 25 години
родител
ревизия
d6a236092c
променени са 6 файла, в които са добавени 74 реда и са изтрити 6 реда
  1. 2 2
      docs/linuxex/Makefile
  2. 2 0
      docs/linuxex/README
  3. 2 3
      docs/linuxex/ex36.pp
  4. 1 1
      docs/linuxex/ex57.pp
  5. 36 0
      docs/linuxex/ex64.pp
  6. 31 0
      docs/linuxex/ex65.pp

+ 2 - 2
docs/linuxex/Makefile

@@ -36,8 +36,8 @@ OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12 ex13 ex14 \
         ex15 ex16 ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 \
         ex28 ex29 ex30 ex31 ex32 ex33 ex34 ex35 ex36 ex37 ex38 ex39 ex40 \
         ex41 ex42 ex43 ex44 ex45 ex46 ex47 ex48 ex49 ex51 ex52 ex53 ex54 ex55 \
-        ex56 ex57 ex58 ex59  ex60 ex61 ex62 ex63 
-# ex64 ex65 ex66 \
+        ex56 ex57 ex58 ex59  ex60 ex61 ex62 ex63  ex64 ex65
+# ex66 \
 #        ex67 ex68 ex69 ex70 ex71 ex72 ex73 ex74 ex75 ex76 ex77
 
 TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))

+ 2 - 0
docs/linuxex/README

@@ -65,3 +65,5 @@ serial.pp contains an example of serial port programming in FPC.
 ex61.pp contains an example of the CreateShellArgV function.
 ex62.pp contains an example of the ReadLink function.
 ex63.pp contains an example of the FRename function.
+ex64.pp contains an example of the SysInfo function.
+ex64.pp contains an example of the SigRaise function.

+ 2 - 3
docs/linuxex/ex36.pp

@@ -9,9 +9,8 @@ Var pipi,pipo : Text;
     
 begin
   Writeln ('Assigning Pipes.');
-  assignpipe(pipi,pipo);
-  if linuxerror<>0 then 
-    Writeln('Error assigning pipes !');
+  If Not assignpipe(pipi,pipo) then
+    Writeln('Error assigning pipes !',LinuxError);
   Writeln ('Writing to pipe, and flushing.');
   Writeln (pipo,'This is a textstring');close(pipo);
   Writeln ('Reading from pipe.');

+ 1 - 1
docs/linuxex/ex57.pp

@@ -22,7 +22,7 @@ end;
 begin
    new(na);
    new(oa);
-   na^.Sa_Handler:=@DoSig;
+   na^.Handler.sh:=@DoSig;
    na^.Sa_Mask:=0;
    na^.Sa_Flags:=0;
    na^.Sa_Restorer:=Nil;

+ 36 - 0
docs/linuxex/ex64.pp

@@ -0,0 +1,36 @@
+program Example64;
+
+{ Example to demonstrate the SysInfo function }
+
+Uses Linux;
+
+Function Mb(L : Longint) : longint;
+
+begin
+  Mb:=L div (1024*1024);
+end;
+   
+Var Info : TSysInfo;
+    D,M,Secs,H : longint;
+
+begin
+  If Not SysInfo(Info) then 
+    Halt(1);
+  With Info do
+    begin
+    D:=Uptime div (3600*24);
+    UpTime:=UpTime mod (3600*24);
+    h:=uptime div 3600;
+    uptime:=uptime mod 3600;
+    m:=uptime div 60;
+    secs:=uptime mod 60;
+    Writeln('Uptime : ',d,'days, ',h,' hours, ',m,' min, ',secs,' s.');
+    Writeln('Loads  : ',Loads[1],'/',Loads[2],'/',Loads[3]);
+    Writeln('Total Ram  : ',Mb(totalram),'Mb.');
+    Writeln('Free Ram   : ',Mb(freeram),'Mb.');
+    Writeln('Shared Ram : ',Mb(sharedram),'Mb.');
+    Writeln('Buffer Ram : ',Mb(bufferram),'Mb.');
+    Writeln('Total Swap : ',Mb(totalswap),'Mb.');
+    Writeln('Free Swap  : ',Mb(freeswap),'Mb.');
+    end;
+end.

+ 31 - 0
docs/linuxex/ex65.pp

@@ -0,0 +1,31 @@
+Program example64;
+
+{ Program to demonstrate the SigRaise function.}
+
+uses Linux;
+
+Var
+   oa,na : PSigActionRec;
+   
+Procedure DoSig(sig : Longint);cdecl;
+
+begin
+   writeln('Receiving signal: ',sig);
+end; 
+
+begin
+   new(na);
+   new(oa);
+   na^.handler.sh:=@DoSig;
+   na^.Sa_Mask:=0;
+   na^.Sa_Flags:=0;
+   na^.Sa_Restorer:=Nil;
+   SigAction(SigUsr1,na,oa);
+   if LinuxError<>0 then
+     begin
+     writeln('Error: ',linuxerror,'.');
+     halt(1);
+     end;
+   Writeln('Sending USR1 (',sigusr1,') signal to self.');
+   SigRaise(sigusr1);
+end.