Ñèñòåìíîå ïðîãðàììèðîâàíèå â UNIX ñðåäñòâàìè Free Pascal

       

Óïðàâëåíèå ïðîöåññàìè


Óïðàæíåíèå 13.51. Ñîçäàéòå ïðîñòåéøèé êîìàíäíûé èíòåðïðåòàòîð.

uses dos;

var

  cmd:string;

begin

  while true do

  begin

    write('> ');

    readln(cmd);

    if cmd='exit' then

      break

    else

    begin



      cmd:='-c '+cmd;

      writeln('Ââåäåíà êîìàíäà ',cmd);

      exec('/bin/sh',cmd);

    end;

  end;

end.

 

Óïðàæíåíèå 13.52. Ñîçäàéòå ïðîãðàììó, âûâîäÿùóþ óñòàíîâëåííûå äëÿ ïðîöåññà îãðàíè÷åíèÿ.

uses linux;

const

    _SC_ARG_MAX=1;

    _SC_CHILD_MAX=2;

    _SC_CLK_TCK=3;

    _SC_NGROUPS_MAX=4;

    _SC_OPEN_MAX=5;

    _SC_STREAM_MAX=6;

    _SC_TZNAME_MAX=7;

    _SC_JOB_CONTROL=8;

    _SC_SAVED_IDS=9;

    _SC_REALTIME_SIGNALS=10;

    _SC_PRIORITY_SCHEDULING=11;

    _SC_TIMERS=12;

    _SC_ASYNCHRONOUS_IO=13;

    _SC_PRIORITIZED_IO=14;

    _SC_SYNCHRONIZED_IO=15;

    _SC_FSYNC=16;

    _SC_MAPPED_FILES=17;

    _SC_MEMLOCK=18;

    _SC_MEMLOCK_RANGE=19;

    _SC_MEMORY_PROTECTION=20;

    _SC_MESSAGE_PASSING=21;

    _SC_SEMAPHORES=22;

    _SC_SHARED_MEMORY_OBJECTS=23;

    _SC_AIO_LISTIO_MAX=24;

    _SC_AIO_MAX=25;

    _SC_AIO_PRIO_DELTA_MAX=26;

    _SC_DELAYTIMER_MAX=27;

    _SC_MQ_OPEN_MAX=28;

    _SC_MQ_PRIO_MAX=29;

    _SC_VERSION=30;

    _SC_PAGESIZE=31;

    _SC_RTSIG_MAX=32;

    _SC_SEM_NSEMS_MAX=33;

    _SC_SEM_VALUE_MAX=34;

    _SC_SIGQUEUE_MAX=35;

    _SC_TIMER_MAX=36;

    _SC_BC_BASE_MAX=37;

    _SC_BC_DIM_MAX=38;

    _SC_BC_SCALE_MAX=39;

    _SC_BC_STRING_MAX=40;

    _SC_COLL_WEIGHTS_MAX=41;

    _SC_EQUIV_CLASS_MAX=42;

    _SC_EXPR_NEST_MAX=43;

    _SC_LINE_MAX=44;

    _SC_RE_DUP_MAX=45;

    _SC_CHARCLASS_NAME_MAX=46;

    _SC_2_VERSION=47;

    _SC_2_C_BIND=48;

    _SC_2_C_DEV=49;

    _SC_2_FORT_DEV=50;

    _SC_2_FORT_RUN=51;

    _SC_2_SW_DEV=52;

    _SC_2_LOCALEDEF=53;

    _SC_PII=54;

    _SC_PII_XTI=55;

    _SC_PII_SOCKET=56;

    _SC_PII_INTERNET=57;

    _SC_PII_OSI=58;

    _SC_POLL=59;

    _SC_SELECT=60;

    _SC_UIO_MAXIOV=61;

    _SC_IOV_MAX=62;

    _SC_PII_INTERNET_STREAM=63;




ààà _SC_PII_INTERNET_DGRAM=64;

ààà _SC_PII_OSI_COTS=65;

ààà _SC_PII_OSI_CLTS=66;

ààà _SC_PII_OSI_M=67;

ààà _SC_T_IOV_MAX=68;

ààà _SC_THREADS=69;

ààà _SC_THREAD_SAFE_FUNCTIONS=70;

ààà _SC_GETGR_R_SIZE_MAX=71;

ààà _SC_GETPW_R_SIZE_MAX=72;

ààà _SC_LOGIN_NAME_MAX=73;

ààà _SC_TTY_NAME_MAX=74;

ààà _SC_THREAD_DESTRUCTOR_ITERATIONS=75;

ààà _SC_THREAD_KEYS_MAX=76;

ààà _SC_THREAD_STACK_MIN=77;

ààà _SC_THREAD_THREADS_MAX=78;

ààà _SC_THREAD_ATTR_STACKADDR=79;

ààà _SC_THREAD_ATTR_STACKSIZE=80;

ààà _SC_THREAD_PRIORITY_SCHEDULING=81;

ààà _SC_THREAD_PRIO_INHERIT=82;

ààà _SC_THREAD_PRIO_PROTECT=83;

ààà _SC_THREAD_PROCESS_SHARED=84;

ààà _SC_NPROCESSORS_CONF=85;

ààà _SC_NPROCESSORS_ONLN=86;

ààà _SC_PHYS_PAGES=87;

ààà _SC_AVPHYS_PAGES=88;

ààà _SC_ATEXIT_MAX=89;

ààà _SC_PASS_MAX=90;

ààà _SC_XOPEN_VERSION=91;

ààà _SC_XOPEN_XCU_VERSION=92;

ààà _SC_XOPEN_UNIX=93;

ààà _SC_XOPEN_CRYPT=94;

ààà _SC_XOPEN_ENH_I18N=95;

ààà _SC_XOPEN_SHM=96;

ààà _SC_2_CHAR_TERM=97;

ààà _SC_2_C_VERSION=98;

ààà _SC_2_UPE=99;

ààà _SC_XOPEN_XPG2=100;

ààà _SC_XOPEN_XPG3=101;

ààà _SC_XOPEN_XPG4=102;

ààà _SC_CHAR_BIT=103;

ààà _SC_CHAR_MAX=104;

ààà _SC_CHAR_MIN=105;

ààà _SC_INT_MAX=106;

ààà _SC_INT_MIN=107;

ààà _SC_LONG_BIT=108;

ààà _SC_WORD_BIT=109;

ààà _SC_MB_LEN_MAX=110;

ààà _SC_NZERO=111;

ààà _SC_SSIZE_MAX=112;

ààà _SC_SCHAR_MAX=113;

ààà _SC_SCHAR_MIN=114;

ààà _SC_SHRT_MAX=115;

ààà _SC_SHRT_MIN=116;

ààà _SC_UCHAR_MAX=117;

ààà _SC_UINT_MAX=118;

ààà _SC_ULONG_MAX=119;

ààà _SC_USHRT_MAX=120;

ààà _SC_NL_ARGMAX=121;

ààà _SC_NL_LANGMAX=122;

ààà _SC_NL_MSGMAX=123;

ààà _SC_NL_NMAX=124;

ààà _SC_NL_SETMAX=125;

ààà _SC_NL_TEXTMAX=126;

ààà _SC_XBS5_ILP32_OFF32=127;

ààà _SC_XBS5_ILP32_OFFBIG=128;

ààà _SC_XBS5_LP64_OFF64=129;

ààà _SC_XBS5_LPBIG_OFFBIG=130;

ààà _SC_XOPEN_LEGACY=131;

ààà _SC_XOPEN_REALTIME=132;

ààà _SC_XOPEN_REALTIME_THREADS=133;

ààà _SC_ADVISORY_INFO=134;

ààà _SC_BARRIERS=135;

ààà _SC_BASE=136;

ààà _SC_C_LANG_SUPPORT=137;

ààà _SC_C_LANG_SUPPORT_R=138;



ààà _SC_CLOCK_SELECTION=139;

àà à_SC_CPUTIME=140;

ààà _SC_THREAD_CPUTIME=141;

ààà _SC_DEVICE_IO=142;

ààà _SC_DEVICE_SPECIFIC=143;

ààà _SC_DEVICE_SPECIFIC_R=144;

ààà _SC_FD_MGMT=145;

ààà _SC_FIFO=146;

ààà _SC_PIPE=147;

ààà _SC_FILE_ATTRIBUTES=148;

ààà _SC_FILE_LOCKING=149;

ààà _SC_FILE_SYSTEM=150;

ààà _SC_MONOTONIC_CLOCK=151;

ààà _SC_MULTI_PROCESS=152;

ààà _SC_SINGLE_PROCESS=153;

ààà _SC_NETWORKING=154;

ààà _SC_READER_WRITER_LOCKS=155;

ààà _SC_SPIN_LOCKS=156;

ààà _SC_REGEXP=157;

ààà _SC_REGEX_VERSION=158;

ààà _SC_SHELL=159;

ààà _SC_SIGNALS=160;

ààà _SC_SPAWN=161;

ààà _SC_SPORADIC_SERVER=162;

ààà _SC_THREAD_SPORADIC_SERVER=163;

ààà _SC_SYSTEM_DATABASE=164;

ààà _SC_SYSTEM_DATABASE_R=165;

ààà _SC_TIMEOUTS=166;

ààà _SC_TYPED_MEMORY_OBJECTS=167;

ààà _SC_USER_GROUPS=168;

ààà _SC_USER_GROUPS_R=169;

ààà _SC_2_PBS=170;

ààà _SC_2_PBS_ACCOUNTING=171;

ààà _SC_2_PBS_LOCATE=172;

ààà _SC_2_PBS_MESSAGE=173;

ààà _SC_2_PBS_TRACK=174;

ààà _SC_SYMLOOP_MAX=175;

ààà _SC_STREAMS=176;

ààà _SC_2_PBS_CHECKPOINT=177;

ààà _SC_V6_ILP32_OFF32=178;

ààà _SC_V6_ILP32_OFFBIG=179;

ààà _SC_V6_LP64_OFF64=180;

ààà _SC_V6_LPBIG_OFFBIG=181;

ààà _SC_HOST_NAME_MAX=182;

ààà _SC_TRACE=183;

ààà _SC_TRACE_EVENT_FILTER=184;

ààà _SC_TRACE_INHERIT=185;

ààà _SC_TRACE_LOG=186;

type struct=record

à name:integer;

à value:string;

end;

function sysconf(name:integer):longint;cdecl;external 'c';

const

à count=20;

à mas:array [1..count] of struct=(

à (name:_SC_ARG_MAX;value:' üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_CHILD_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name: _SC_CLK_TCK;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_NGROUPS_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_OPEN_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_STREAM_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),



à (name:_SC_TZNAME_MAX;value:' üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_JOB_CONTROL;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_ARG_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_SAVED_IDS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_REALTIME_SIGNALS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PRIORITY_SCHEDULING;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_TIMERS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_ASYNCHRONOUS_IO;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PRIORITIZED_IO;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_SYNCHRONIZED_IO;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_FSYNC;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_MAPPED_FILES;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_MEMLOCK;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_MEMLOCK_RANGE;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec')

à (name:_SC_MEMORY_PROTECTION;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_CHILD_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_MESSAGE_PASSING;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_SEMAPHORES;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_SHARED_MEMORY_OBJECTS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_AIO_LISTIO_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_AIO_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_AIO_PRIO_DELTA_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_DELAYTIMER_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),



à (name:_SC_MQ_OPEN_MAX;value:' üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_MQ_PRIO_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_VERSION;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_PAGESIZE;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_RTSIG_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_SEM_NSEMS_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_SEM_VALUE_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_SIGQUEUE_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_TIMER_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_BC_BASE_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_BC_DIM_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_BC_SCALE_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_BC_STRING_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_COLL_WEIGHTS_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_EQUIV_CLASS_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_EXPR_NEST_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_LINE_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_RE_DUP_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_CHARCLASS_NAME_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_2_VERSION;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_2_C_BIND;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_2_C_DEV;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_2_FORT_DEV;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),



à

à (name:_SC_2_FORT_RUN;value:' üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_2_SW_DEV;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_2_LOCALEDEF;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PII;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_PII_XTI;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PII_SOCKET;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_PII_INTERNET;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PII_OSI;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_POLL;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_SELECT;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_UIO_MAXIOV;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_IOV_MAX;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_PII_INTERNET_STREAM;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PII_INTERNET_DGRAM;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_PII_OSI_COTS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_PII_OSI_CLTS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:_SC_PII_OSI_M;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:_SC_T_IOV_MAX;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:_SC_THREADS;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à

à (name:;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:;value:'üðú¸øüðû¹ýþõ úþûø¢õ¸ªòþ ÿ¨þ¡õ¸¸þò ýð þôýþóþ ÿþû¹÷þòðªõû '),

à (name:;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),

à (name:;value:'üðú¸øüðû¹ýð  ôûøýð ð¨óºüõýªþò ¯ºýú¡øù ¸õüõù¸ªòð exec'),



à

à);

var

à i:integer;

begin

à for i:=1 to count do

ààà writeln(mas[i].value,' = ',sysconf(mas[i].name));

end.

 

Lÿ¨ðöýõýøõ 13.53. =ðÿø°øªõ ÿ¨þó¨ðüüº, ÿõ¢ðªð¦•º¦ ¸òþø ÿð¨ðüõª¨v ø ÷ýð¢õýøõ ÿõ¨òv¿ ôõ¸ ªø ÿõ¨õüõýýv¿ þú¨ºöõýø .

program Parameters;

uses Dos,Crt;

var

à i:Byte;

begin

à ClrScr;

à if ParamCount>1 then

àà begin

ààà Writeln('Owner parameters:');

ààà For i:=1 to ParamCount do

ààààà Writeln(Paramstr(i));

àà end

à else Writeln('No owner parameters.');

à Writeln('System parameters:');

à if envcount<10 then

ààà for i := 1 to EnvCount do

ààààà Writeln(EnvStr(i))

à else

ààà for i := 1 to 10 do

ààààà Writeln(EnvStr(i));

end.

 

Lÿ¨ðöýõýøõ 13.54. =ðÿø°øªõ ÿ¨þó¨ðüüº, º÷ý𦕺¦ º ¸ø¸ªõüv ø ¨ð¸ÿõ¢ðªvò𦕺¦: ýþüõ¨ ÿ¨þ¡õ¸¸ð, ýþüõ¨ ø øü  ¸òþõóþ òûðôõû¹¡ð, ýþüõ¨ ó¨ºÿÿv, ýð÷òðýøõ ø ªøÿ ªõ¨üøýðûð, ýð úþªþ¨þü þýð ¨ðñþªðõª.

uses linux;

function getnamebyuid(uid:longint):string;

var

à f:text;

à s,name:string;

à n,res:integer;

begin

à assign(f,'/etc/passwd');

à reset(f);

à while not eof(f) do

à begin

ààà readln(f,s);

ààà n:=pos(':',s);

ààà name:=copy(s,1,n-1);

ààà delete(s,1,n+2);

ààà n:=pos(':',s);

ààà delete(s,n,length(s)-n+1);

ààà val(s,res);

ààà if uid=res then

ààà begin

ààààà getnamebyuid:=name;

àà àààexit;

ààà end;

à end;

à getnamebyuid:='';

end;

var

à pid,uid,gid:longint;

à name,term:string;

à t:termios;

begin

à pid:=getpid;

à uid:=getuid;

à gid:=getgid;

à name:=getnamebyuid(uid);

à term:=getenv('TERM');

à tcgetattr(0,t);

à writeln('=þüõ¨ ÿ¨þ¡õ¸¸ð - ',pid);

à writeln('¦¨þ¡õ¸¸ ÿ¨øýðôûõöøª ÿþû¹÷þòðªõû¦ ¸ ýþüõ¨þü ',uid, ' ÿþ øüõýø ',name);

à writeln('¦¨þ¡õ¸¸ ò¿þôøª ò ó¨ºÿÿº ',gid);

à write('¦¨þ¡õ¸¸ òvÿþûý õª¸  ýð ');

à if (t.c_lflag and ICANON)=0 then

ààà write('ýõ');

à writeln('úðýþýø¢õ¸úþü ªõ¨üøýðûõ ',term);

end.

Lÿ¨ðöýõýøõ 13.55. =ðÿø°øªõ ÿ¨þó¨ðüüº, òvñþ¨þ¢ýþ òvòþô •º¦ ÷ýð¢õýøõ ÿõ¨õüõýýv¿ þú¨ºöõýø  ø º¸ªðýðòûøò𦕺¦ ýþòvõ ÷ýð¢õýø  ÿþ öõûðýø¦ ÿþû¹÷þòðªõû .



uses crt,dos;

var i:integer;

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

ààà

ààà c:char;

function setenv(s1,s2:pchar;ower:integer):integer;cdecl;external 'c';

begin

à for i:=1 to envcount do

ààà writeln(envstr(i),'=',getenv(envstr(i)));à

à writeln(' Tòõôøªõ ÿõ¨õüõýýº¦ þú¨ºöõýø , ýþ ªþû¹úþ ñþû¹°øüø ñºúòðüø.');

à readln(s);

à if getenv(strpas(s))<>'' then

ààà writeln(getenv(strpas(s)))

à else

à begin

ààà writeln('¦õ¨õüõýýþù þú¨ºöõýø  ',s,' ýõ ¸º•õ¸ªòºõª');

ààà halt;

à end;

à writeln('-þªøªõ ø÷üõýøª¹ ÷ýð¢õýøõ ',s,' ýðöüøªõà "y" ');

à c:=readkey;

à if upcase(c)='Y' then

à begin

ààà writeln('Tòõôøªõ ÷ýð¢õýøõ ÿõ¨õüõýýþù');

ààà readln(st);

ààà if setenv(s,st,1)<0 then

ààààà writeln('¦ýð¢õýøõ ÿõ¨õüõýýþù ýõ ÿþüõý ûþ¸¹')

ààà else

ààààà writeln(setenv(s,st,1),' ',getenv(strpas(s)));

à end;

end.

Lÿ¨ðöýõýøõ 13.56. =ðÿø°øªõ ¯ºýú¡ø¦ sleep(n), ÷ðôõ¨öøò𦕺¦ òvÿþûýõýøõ ÿ¨þó¨ðüüv ýð n ¸õúºýô. Tþ¸ÿþû¹÷ºùªõ¸¹ ¸ø¸ªõüývü òv÷þòþü alarm(n) (ñºôøû¹ýøú) ø òv÷þòþü pause(), úþªþ¨vù ÷ðôõ¨öøòðõª ÿ¨þó¨ðüüº ôþ ÿþûº¢õýø  û¦ñþóþ ¸øóýðûð. ¦¨õôº¸üþª¨øªõ ¨õ¸ªð¨ª ÿ¨ø ÿþûº¢õýøø òþ ò¨õü  þöøôðýø  ô¨ºóþóþ ¸øóýðûð, ýõöõûø SIGALRM. Tþ¿¨ðý ùªõ ÷ðúð÷ alarm, ¸ôõûðýývù ôþ òv÷þòð sleep (alarm òvôðõª ¢ø¸ûþ ¸õúºýô, þ¸ªðò°õõ¸  ôþ ÷ðòõ¨°õýø  ÿ¨õôvôº•õóþ ÷ðúð÷ð).

uses dos,crt,sysutils,linux;

à

procedure handler(sig:integer);cdecl;

begin

end;

à

procedure sleep(count:integer);

var

à oldhandler,newhandler:sigactionrec;

begin

ààààà

à writeln('count=',count);

à newhandler.handler.sh:=@handler;

à (*newhandler.sa_mask:=$ffffffff;*)

à newhandler.sa_mask:=0;

à sigaction(SIGALRM,@newhandler,@oldhandler);

à alarm(count);

à pause;

à sigaction(SIGALRM,@oldhandler,nil);

end;

begin

repeat

sleep(3);

writeln('¦¨øòõª');

until keypressed;

end.


Ñîäåðæàíèå ðàçäåëà