UNIX Free Pascal


. proc


13.35. , : , , .

uses dos,linux,strings;

var

i,n,pid:integer;

s,fullname:array [0..200] of char;

temp:string;

d:pdir;

el:pdirent;

begin

i:=fdopen('/etc/passwd',Open_RDONLY);

n:=paramcount;

writeln(' ',paramcount+1, ' ');

for i:=0 to n do

writeln(' ',i+1,' - ',paramstr(i));

writeln(' :');

n:=envcount;

for i:=1 to n do

writeln(envstr(i));

pid:=getpid;

strcopy(s,'/proc/');

str(pid,temp);

strpcopy(s+strlen(s),temp);

strcat(s,'/fd/');

d:=opendir(pchar(s));

el:=readdir(d);

writeln(', :');

while el<>nil do

begin

if (strcomp(el^.name,'.')<>0) and (strcomp(el^.name,'..')<>0) then

begin

strcopy(fullname,s);

strcat(fullname,el^.name);

writeln(' ',el^.name,' ',readlink(fullname));

end;

el:=readdir(d);

end;

closedir(d);

end.

 

13.36. ps.

uses linux,strings,sysutils; (* Linux PChar*)

 

var

d:^TDir; (* *)

elem:^Dirent; (* , *)

realname, (* status*)

fullpath (* *)

:array [0..1000] of char;

number,coder:integer; (* *)

f:text;

name:string;

begin

d:=opendir('/proc'); (* *)

if d=nil then (* *)

begin

writeln(' opendir /proc'); (**)

halt(1); (* *)

end;

elem:=readdir(d); (* *)




- -  - -  - -