diff --git a/docs/linuxex/Makefile b/docs/linuxex/Makefile index 6fdc79f41e..967a8c102a 100644 --- a/docs/linuxex/Makefile +++ b/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)) diff --git a/docs/linuxex/README b/docs/linuxex/README index 822d2f65cc..c972d7cfbf 100644 --- a/docs/linuxex/README +++ b/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. diff --git a/docs/linuxex/ex36.pp b/docs/linuxex/ex36.pp index 085d596602..eb2217af7e 100644 --- a/docs/linuxex/ex36.pp +++ b/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.'); diff --git a/docs/linuxex/ex57.pp b/docs/linuxex/ex57.pp index 099c695258..60dddf80e6 100644 --- a/docs/linuxex/ex57.pp +++ b/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; diff --git a/docs/linuxex/ex64.pp b/docs/linuxex/ex64.pp new file mode 100644 index 0000000000..8431a75159 --- /dev/null +++ b/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. diff --git a/docs/linuxex/ex65.pp b/docs/linuxex/ex65.pp new file mode 100644 index 0000000000..0e7a5730c4 --- /dev/null +++ b/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. \ No newline at end of file