unix.pp 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. BSD parts (c) 2000 by Marco van de Voort
  6. members of the Free Pascal development team.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. Unit Unix;
  14. Interface
  15. Uses BaseUnix,UnixType;
  16. {$i aliasptp.inc}
  17. //type
  18. // pathstr = string[255];
  19. {$define POSIXWORKAROUND}
  20. { Get Types and Constants }
  21. {$i sysconst.inc}
  22. {$ifdef FreeBSD}
  23. {$i systypes.inc}
  24. {$else}
  25. {$ifndef FPC_USE_LIBC}
  26. {$i systypes.inc}
  27. {$endif FPC_USE_LIBC}
  28. {$endif}
  29. {Get error numbers, some more signal definitions and other OS dependant
  30. types (that are not POSIX) }
  31. {i errno.inc}
  32. {$I signal.inc}
  33. {$i ostypes.inc}
  34. // We init to zero to be able to put timezone stuff under IFDEF, and still
  35. // keep the code working.
  36. var
  37. Tzseconds : Longint {$ifndef ver1_0} = 0 {$endif};
  38. {********************
  39. File
  40. ********************}
  41. Const
  42. P_IN = 1; // pipes (?)
  43. P_OUT = 2;
  44. Const
  45. LOCK_SH = 1; // flock constants ?
  46. LOCK_EX = 2;
  47. LOCK_UN = 8;
  48. LOCK_NB = 4;
  49. Type
  50. Tpipe = baseunix.tfildes; // compability.
  51. {******************************************************************************
  52. Procedure/Functions
  53. ******************************************************************************}
  54. {**************************
  55. Time/Date Handling
  56. ***************************}
  57. var
  58. tzdaylight : boolean;
  59. tzname : array[boolean] of pchar;
  60. {$IFNDEF DONT_READ_TIMEZONE} // allows to disable linking in and trying for platforms
  61. // it doesn't (yet) work for.
  62. { timezone support }
  63. procedure GetLocalTimezone(timer:cint;var leap_correct,leap_hit:cint);
  64. procedure GetLocalTimezone(timer:cint);
  65. procedure ReadTimezoneFile(fn:string);
  66. function GetTimezoneFile:string;
  67. {$ENDIF}
  68. {**************************
  69. Process Handling
  70. ***************************}
  71. //
  72. // These are much better, in nearly all ways.
  73. //
  74. function FpExecLE (Const PathName:AnsiString;const S:Array Of AnsiString;MyEnv:ppchar):cint;
  75. function FpExecL(Const PathName:AnsiString;const S:Array Of AnsiString):cint;
  76. function FpExecLP(Const PathName:AnsiString;const S:Array Of AnsiString):cint;
  77. function FpExecV(Const PathName:AnsiString;args:ppchar):cint;
  78. function FpExecVP(Const PathName:AnsiString;args:ppchar):cint;
  79. function FpExecVPE(Const PathName:AnsiString;args,env:ppchar):cint;
  80. Function Shell (const Command:String):cint;
  81. Function Shell (const Command:AnsiString):cint;
  82. Function fpSystem(const Command:AnsiString):cint;
  83. Function WaitProcess (Pid:cint):cint; { like WaitPid(PID,@result,0) Handling of Signal interrupts (errno=EINTR), returning the Exitcode of Process (>=0) or -Status if terminated}
  84. Function WIFSTOPPED (Status: Integer): Boolean;
  85. Function W_EXITCODE (ReturnCode, Signal: Integer): Integer;
  86. Function W_STOPCODE (Signal: Integer): Integer;
  87. {**************************
  88. File Handling
  89. ***************************}
  90. {$ifndef FPC_USE_LIBC} // defined using cdecl for libc.
  91. Function fsync (fd : cint) : cint;
  92. Function fpFlock (fd,mode : cint) : cint ;
  93. Function fStatFS (Fd: cint;Var Info:tstatfs):cint;
  94. Function StatFS (Path:pchar;Var Info:tstatfs):cint;
  95. {$endif}
  96. Function fpFlock (var T : text;mode : cint) : cint;
  97. Function fpFlock (var F : File;mode : cint) : cint;
  98. Function SelectText (var T:Text;TimeOut :PTimeVal):cint;
  99. Function SelectText (var T:Text;TimeOut :cint):cint;
  100. {**************************
  101. Directory Handling
  102. ***************************}
  103. procedure SeekDir(p:pdir;loc:clong);
  104. function TellDir(p:pdir):clong;
  105. {**************************
  106. Pipe/Fifo/Stream
  107. ***************************}
  108. Function AssignPipe (var pipe_in,pipe_out:cint):cint;
  109. Function AssignPipe (var pipe_in,pipe_out:text):cint;
  110. Function AssignPipe (var pipe_in,pipe_out:file):cint;
  111. //Function PClose (Var F:text) : cint;
  112. //Function PClose (Var F:file) : cint;
  113. Function POpen (var F:text;const Prog:String;rw:char):cint;
  114. Function POpen (var F:file;const Prog:String;rw:char):cint;
  115. Function AssignStream(Var StreamIn,Streamout:text;Const Prog:ansiString;const args : array of ansistring) : cint;
  116. Function AssignStream(Var StreamIn,Streamout,streamerr:text;Const Prog:ansiString;const args : array of ansistring) : cint;
  117. Function GetDomainName:String;
  118. Function GetHostName:String;
  119. {**************************
  120. Memory functions
  121. ***************************}
  122. const
  123. PROT_READ = $1; { page can be read }
  124. PROT_WRITE = $2; { page can be written }
  125. PROT_EXEC = $4; { page can be executed }
  126. PROT_NONE = $0; { page can not be accessed }
  127. MAP_SHARED = $1; { Share changes }
  128. // MAP_PRIVATE = $2; { Changes are private }
  129. MAP_TYPE = $f; { Mask for type of mapping }
  130. MAP_FIXED = $10; { Interpret addr exactly }
  131. // MAP_ANONYMOUS = $20; { don't use a file }
  132. {$ifdef Linux}
  133. MAP_GROWSDOWN = $100; { stack-like segment }
  134. MAP_DENYWRITE = $800; { ETXTBSY }
  135. MAP_EXECUTABLE = $1000; { mark it as an executable }
  136. MAP_LOCKED = $2000; { pages are locked }
  137. MAP_NORESERVE = $4000; { don't check for reservations }
  138. {$else}
  139. {$ifdef FreeBSD}
  140. // FreeBSD defines MAP_COPY=MAP_PRIVATE=$2;
  141. MAP_FILE = $0000; { map from file (default) }
  142. MAP_ANON = $1000; { allocated from memory, swap space }
  143. MAP_RENAME = $0020; { Sun: rename private pages to file }
  144. MAP_NORESERVE = $0040; { Sun: don't reserve needed swap area }
  145. MAP_INHERIT = $0080; { region is retained after exec }
  146. MAP_NOEXTEND = $0100; { for MAP_FILE, don't change file size }
  147. MAP_HASSEMAPHORE = $0200; { region may contain semaphores }
  148. MAP_STACK = $0400; { region grows down, like a stack }
  149. MAP_NOSYNC = $0800; { page to but do not sync underlying file}
  150. MAP_NOCORE = $20000;{ dont include these pages in a coredump}
  151. {$endif}
  152. {$endif}
  153. {**************************
  154. Utility functions
  155. ***************************}
  156. Type
  157. TFSearchOption = (NoCurrentDirectory,
  158. CurrentDirectoryFirst,
  159. CurrentDirectoryLast);
  160. Function FSearch (const path:AnsiString;dirlist:Ansistring;CurrentDirStrategy:TFSearchOption):AnsiString;
  161. Function FSearch (const path:AnsiString;dirlist:AnsiString):AnsiString;
  162. procedure SigRaise (sig:integer);
  163. {$ifdef FPC_USE_LIBC}
  164. const clib = 'c';
  165. {$i unxdeclh.inc}
  166. {$else}
  167. {$i unxsysch.inc} // calls used in system and not reexported from baseunix
  168. {$endif}
  169. {******************************************************************************
  170. Implementation
  171. ******************************************************************************}
  172. {$i unxovlh.inc}
  173. Implementation
  174. Uses Strings{$ifndef FPC_USE_LIBC},Syscall{$endif};
  175. {$i unxovl.inc}
  176. {$ifndef FPC_USE_LIBC}
  177. {$i syscallh.inc}
  178. {$i ossysch.inc}
  179. {$i unxsysc.inc}
  180. {$endif}
  181. { Get the definitions of textrec and filerec }
  182. {$i textrec.inc}
  183. {$i filerec.inc}
  184. {$ifndef FPC_USE_LIBC}
  185. { Raw System calls are in Syscalls.inc}
  186. {$ifdef Linux} // Linux has more "oldlinux" compability.
  187. {$i sysc11.inc}
  188. {$else}
  189. {$i syscalls.inc}
  190. {$endif}
  191. {$endif}
  192. {$i unixsysc.inc} {Has platform specific libc part under ifdef, besides
  193. syscalls}
  194. Function getenv(name:string):Pchar; external name 'FPC_SYSC_FPGETENV';
  195. {******************************************************************************
  196. Process related calls
  197. ******************************************************************************}
  198. { Most calls of WaitPID do not handle the result correctly, this funktion treats errors more correctly }
  199. Function WaitProcess(Pid:cint):cint; { like WaitPid(PID,@result,0) Handling of Signal interrupts (errno=EINTR), returning the Exitcode of Process (>=0) or -Status if terminated}
  200. var ret,r,s : cint;
  201. begin
  202. s:=$7F00;
  203. repeat
  204. r:=fpWaitPid(Pid,@s,0);
  205. if (r=-1) and (fpgeterrno=ESysEIntr) Then
  206. r:=0;
  207. until (r<>0);
  208. if (r=-1) or (r=0) then // 0 is not a valid return and should never occur (it means status invalid when using WNOHANG)
  209. WaitProcess:=-1 // return -1 to indicate an error. fpwaitpid updated it.
  210. else
  211. begin
  212. {$ifndef Solaris}
  213. { at least correct for Linux and Darwin (JM) }
  214. if (s and $7F)=0 then // Only this is a valid returncode
  215. {$else}
  216. if (s and $FF)=0 then // Only this is a valid returncode
  217. {$endif}
  218. WaitProcess:=s shr 8
  219. else if (s>0) then // Until now there is not use of the highest bit , but check this for the future
  220. WaitProcess:=-s // normal case
  221. else
  222. WaitProcess:=s; // s<0 should not occur, but wie return also a negativ value
  223. end;
  224. end;
  225. function intFpExecVEMaybeP (Const PathName:AnsiString;Args,MyEnv:ppchar;SearchPath:Boolean):cint;
  226. // does an ExecVE, but still has to handle P
  227. // execv variants call this directly, execl variants indirectly via
  228. // intfpexecl
  229. Var
  230. NewCmd : ansistring;
  231. ThePath : AnsiString;
  232. Error : cint;
  233. NrParam : longint;
  234. Begin
  235. If SearchPath and (pos('/',pathname)=0) Then
  236. Begin
  237. // The above could be better. (check if not escaped/quoted '/'s) ?
  238. // (Jilles says this is ok)
  239. // Stevens says only search if newcmd contains no '/'
  240. // fsearch is not ansistring clean yet.
  241. ThePath:=fpgetenv('PATH');
  242. if thepath='' then
  243. thepath:='.'; // FreeBSD uses _PATH_DEFPATH = /usr/bin:/bin
  244. // but a quick check showed that _PATH_DEFPATH
  245. // varied from OS to OS
  246. newcmd:=FSearch(pathname,thepath,NoCurrentDirectory);
  247. // FreeBSD libc keeps on trying till a file is successfully run.
  248. // Stevens says "try each path prefix"
  249. // execp puts newcmd here.
  250. args^:=pchar(newcmd);
  251. End;
  252. // repeat
  253. // if searchpath then args^:=pchar(commandtorun)
  254. IntFpExecVEMaybeP:=fpExecVE(Args^,Args,MyEnv);
  255. {
  256. // Code that if exec fails due to permissions, tries to run it with sh
  257. // Should we deallocate p on fail? -> no fpexit is run no matter what
  258. //
  259. }
  260. // if intfpexecvemaybep=-1 then zoekvolgende file.
  261. // until (Goexit) or SearchExit;
  262. {
  263. If IntFpExec=-1 Then
  264. Begin
  265. Error:=fpGetErrno
  266. Case Error of
  267. ESysE2Big : Exit(-1);
  268. ESysELoop,
  269. : Exit(-1);
  270. }
  271. end;
  272. function intFpExecl (Const PathName:AnsiString;const s:array of ansistring;MyEnv:ppchar;SearchPath:Boolean):cint;
  273. { Handles the array of ansistring -> ppchar conversion.
  274. Base for the the "l" variants.
  275. }
  276. var p:ppchar;
  277. begin
  278. If PathName='' Then
  279. Begin
  280. fpsetErrno(ESysEnoEnt);
  281. Exit(-1); // Errno?
  282. End;
  283. p:=ArrayStringToPPchar(s,1);
  284. if p=NIL Then
  285. Begin
  286. GetMem(p,2*sizeof(pchar));
  287. if p=nil then
  288. begin
  289. {$ifdef xunix}
  290. fpseterrno(ESysEnoMem);
  291. {$endif}
  292. fpseterrno(ESysEnoEnt);
  293. exit(-1);
  294. end;
  295. p[1]:=nil;
  296. End;
  297. p^:=pchar(PathName);
  298. IntFPExecL:=intFpExecVEMaybeP(PathName,p,MyEnv,SearchPath);
  299. // If we come here, no attempts were executed successfully.
  300. Freemem(p);
  301. end;
  302. function FpExecLE (Const PathName:AnsiString;const S:Array Of AnsiString;MyEnv:ppchar):cint;
  303. Begin
  304. FpExecLE:=intFPExecl(PathName,s,MyEnv,false);
  305. End;
  306. function FpExecL(Const PathName:AnsiString;const S:Array Of AnsiString):cint;
  307. Begin
  308. FpExecL:=intFPExecl(PathName,S,EnvP,false);
  309. End;
  310. function FpExecLP(Const PathName:AnsiString;const S:Array Of AnsiString):cint;
  311. Begin
  312. FpExecLP:=intFPExecl(PathName,S,EnvP,True);
  313. End;
  314. function FpExecV(Const PathName:AnsiString;args:ppchar):cint;
  315. Begin
  316. fpexecV:=intFpExecVEMaybeP (PathName,args,envp,false);
  317. End;
  318. function FpExecVP(Const PathName:AnsiString;args:ppchar):cint;
  319. Begin
  320. fpexecVP:=intFpExecVEMaybeP (PathName,args,envp,true);
  321. End;
  322. function FpExecVPE(Const PathName:AnsiString;args,env:ppchar):cint;
  323. Begin
  324. fpexecVPE:=intFpExecVEMaybeP (PathName,args,env,true);
  325. End;
  326. // exect and execvP (ExecCapitalP) are not implement
  327. // Non POSIX anyway.
  328. // Exect turns on tracing for the process
  329. // execvP has the searchpath as array of ansistring ( const char *search_path)
  330. {$define FPC_USE_FPEXEC}
  331. Function Shell(const Command:String):cint;
  332. {
  333. Executes the shell, and passes it the string Command. (Through /bin/sh -c)
  334. The current environment is passed to the shell.
  335. It waits for the shell to exit, and returns its exit status.
  336. If the Exec call failed exit status 127 is reported.
  337. }
  338. { Changed the structure:
  339. - the previous version returns an undefinied value if fork fails
  340. - it returns the status of Waitpid instead of the Process returnvalue (see the doc to Shell)
  341. - it uses exit(127) not ExitProc (The Result in pp386: going on Compiling in 2 processes!)
  342. - ShellArgs are now released
  343. - The Old CreateShellArg gives back pointers to a local var
  344. }
  345. var
  346. {$ifndef FPC_USE_FPEXEC}
  347. p : ppchar;
  348. {$endif}
  349. pid : cint;
  350. begin
  351. {$ifndef FPC_USE_FPEXEC}
  352. p:=CreateShellArgv(command);
  353. {$endif}
  354. pid:=fpfork;
  355. if pid=0 then // We are in the Child
  356. begin
  357. {This is the child.}
  358. {$ifndef FPC_USE_FPEXEC}
  359. fpExecve(p^,p,envp);
  360. {$else}
  361. fpexecl('/bin/sh',['-c',Command]);
  362. {$endif}
  363. fpExit(127); // was Exit(127)
  364. end
  365. else if (pid<>-1) then // Successfull started
  366. Shell:=WaitProcess(pid)
  367. else // no success
  368. Shell:=-1; // indicate an error
  369. {$ifndef FPC_USE_FPEXEC}
  370. FreeShellArgV(p);
  371. {$endif}
  372. end;
  373. Function Shell(const Command:AnsiString):cint;
  374. {
  375. AnsiString version of Shell
  376. }
  377. var
  378. {$ifndef FPC_USE_FPEXEC}
  379. p : ppchar;
  380. {$endif}
  381. pid : cint;
  382. begin { Changes as above }
  383. {$ifndef FPC_USE_FPEXEC}
  384. p:=CreateShellArgv(command);
  385. {$endif}
  386. pid:=fpfork;
  387. if pid=0 then // We are in the Child
  388. begin
  389. {$ifdef FPC_USE_FPEXEC}
  390. fpexecl('/bin/sh',['-c',Command]);
  391. {$else}
  392. fpExecve(p^,p,envp);
  393. {$endif}
  394. fpExit(127); // was exit(127)!! We must exit the Process, not the function
  395. end
  396. else if (pid<>-1) then // Successfull started
  397. Shell:=WaitProcess(pid)
  398. else // no success
  399. Shell:=-1;
  400. {$ifndef FPC_USE_FPEXEC}
  401. FreeShellArgV(p);
  402. {$ENDIF}
  403. end;
  404. {$ifdef FPC_USE_LIBC}
  405. function xfpsystem(p:pchar):cint; cdecl; external clib name 'system';
  406. Function fpSystem(const Command:AnsiString):cint;
  407. begin
  408. fpsystem:=xfpsystem(pchar(command));
  409. end;
  410. {$else}
  411. Function fpSystem(const Command:AnsiString):cint;
  412. {
  413. AnsiString version of Shell
  414. }
  415. var
  416. pid,savedpid : cint;
  417. pstat : cint;
  418. ign,intact,
  419. quitact : SigactionRec;
  420. newsigblock,
  421. oldsigblock : tsigset;
  422. begin { Changes as above }
  423. if command='' then exit(1);
  424. {$ifdef FreeBSD}
  425. ign.sa_handler:=TSigAction(SIG_IGN);
  426. {$else}
  427. ign.sa_handler:=SignalHandler(SIG_IGN);
  428. {$endif}
  429. fpsigemptyset(ign.sa_mask);
  430. ign.sa_flags:=0;
  431. fpsigaction(SIGINT, @ign, @intact);
  432. fpsigaction(SIGQUIT, @ign, @quitact);
  433. fpsigemptyset(newsigblock);
  434. fpsigaddset(newsigblock,SIGCHLD);
  435. fpsigprocmask(SIG_BLOCK,{$ifdef ver1_0}@{$endif}newsigblock,{$ifdef ver1_0}@{$endif}oldsigblock);
  436. pid:=fpfork;
  437. if pid=0 then // We are in the Child
  438. begin
  439. fpsigaction(SIGINT,@intact,NIL);
  440. fpsigaction(SIGQUIT,@quitact,NIL);
  441. fpsigprocmask(SIG_SETMASK,@oldsigblock,NIL);
  442. fpexecl('/bin/sh',['-c',Command]);
  443. fpExit(127); // was exit(127)!! We must exit the Process, not the function
  444. end
  445. else if (pid<>-1) then // Successfull started
  446. begin
  447. savedpid:=pid;
  448. repeat
  449. pid:=fpwaitpid(savedpid,@pstat,0);
  450. until (pid<>-1) and (fpgeterrno()<>ESysEintr);
  451. if pid=-1 Then
  452. fpsystem:=-1
  453. else
  454. fpsystem:=pstat;
  455. end
  456. else // no success
  457. fpsystem:=-1;
  458. fpsigaction(SIGINT,@intact,NIL);
  459. fpsigaction(SIGQUIT,@quitact,NIL);
  460. fpsigprocmask(SIG_SETMASK,@oldsigblock,NIL);
  461. end;
  462. {$endif}
  463. Function WIFSTOPPED(Status: Integer): Boolean;
  464. begin
  465. WIFSTOPPED:=((Status and $FF)=$7F);
  466. end;
  467. Function W_EXITCODE(ReturnCode, Signal: Integer): Integer;
  468. begin
  469. W_EXITCODE:=(ReturnCode shl 8) or Signal;
  470. end;
  471. Function W_STOPCODE(Signal: Integer): Integer;
  472. begin
  473. W_STOPCODE:=(Signal shl 8) or $7F;
  474. end;
  475. {$IFNDEF DONT_READ_TIMEZONE}
  476. { Include timezone handling routines which use /usr/share/timezone info }
  477. {$i timezone.inc}
  478. {$endif}
  479. {******************************************************************************
  480. FileSystem calls
  481. ******************************************************************************}
  482. Function fpFlock (var T : text;mode : cint) : cint;
  483. begin
  484. fpFlock:=fpFlock(TextRec(T).Handle,mode);
  485. end;
  486. Function fpFlock (var F : File;mode : cint) :cint;
  487. begin
  488. fpFlock:=fpFlock(FileRec(F).Handle,mode);
  489. end;
  490. Function SelectText(var T:Text;TimeOut :PTimeval):cint;
  491. Var
  492. F:TfdSet;
  493. begin
  494. if textrec(t).mode=fmclosed then
  495. begin
  496. fpseterrno(ESysEBADF);
  497. exit(-1);
  498. end;
  499. FpFD_ZERO(f);
  500. fpFD_SET(textrec(T).handle,f);
  501. if textrec(T).mode=fminput then
  502. SelectText:=fpselect(textrec(T).handle+1,@f,nil,nil,TimeOut)
  503. else
  504. SelectText:=fpselect(textrec(T).handle+1,nil,@f,nil,TimeOut);
  505. end;
  506. Function SelectText(var T:Text;TimeOut :cint):cint;
  507. var
  508. p : PTimeVal;
  509. tv : TimeVal;
  510. begin
  511. if TimeOut=-1 then
  512. p:=nil
  513. else
  514. begin
  515. tv.tv_Sec:=Timeout div 1000;
  516. tv.tv_Usec:=(Timeout mod 1000)*1000;
  517. p:=@tv;
  518. end;
  519. SelectText:=SelectText(T,p);
  520. end;
  521. {******************************************************************************
  522. Directory
  523. ******************************************************************************}
  524. procedure SeekDir(p:pdir;loc:clong);
  525. begin
  526. if p=nil then
  527. begin
  528. fpseterrno(ESysEBADF);
  529. exit;
  530. end;
  531. {$ifndef bsd}
  532. p^.dd_nextoff:=fplseek(p^.dd_fd,loc,seek_set);
  533. {$endif}
  534. p^.dd_size:=0;
  535. p^.dd_loc:=0;
  536. end;
  537. function TellDir(p:pdir):clong;
  538. begin
  539. if p=nil then
  540. begin
  541. fpseterrno(ESysEBADF);
  542. telldir:=-1;
  543. exit;
  544. end;
  545. telldir:=fplseek(p^.dd_fd,0,seek_cur)
  546. { We could try to use the nextoff field here, but on my 1.2.13
  547. kernel, this gives nothing... This may have to do with
  548. the readdir implementation of libc... I also didn't find any trace of
  549. the field in the kernel code itself, So I suspect it is an artifact of libc.
  550. Michael. }
  551. end;
  552. {******************************************************************************
  553. Pipes/Fifo
  554. ******************************************************************************}
  555. Procedure OpenPipe(var F:Text);
  556. begin
  557. case textrec(f).mode of
  558. fmoutput :
  559. if textrec(f).userdata[1]<>P_OUT then
  560. textrec(f).mode:=fmclosed;
  561. fminput :
  562. if textrec(f).userdata[1]<>P_IN then
  563. textrec(f).mode:=fmclosed;
  564. else
  565. textrec(f).mode:=fmclosed;
  566. end;
  567. end;
  568. Function IOPipe(var F:text):cint;
  569. begin
  570. IOPipe:=0;
  571. case textrec(f).mode of
  572. fmoutput :
  573. begin
  574. { first check if we need something to write, else we may
  575. get a SigPipe when Close() is called (PFV) }
  576. if textrec(f).bufpos>0 then
  577. IOPipe:=fpwrite(textrec(f).handle,pchar(textrec(f).bufptr),textrec(f).bufpos);
  578. end;
  579. fminput : Begin
  580. textrec(f).bufend:=fpread(textrec(f).handle,pchar(textrec(f).bufptr),textrec(f).bufsize);
  581. IOPipe:=textrec(f).bufend;
  582. End;
  583. end;
  584. textrec(f).bufpos:=0;
  585. end;
  586. Function FlushPipe(var F:Text):cint;
  587. begin
  588. FlushPipe:=0;
  589. if (textrec(f).mode=fmoutput) and (textrec(f).bufpos<>0) then
  590. FlushPipe:=IOPipe(f);
  591. textrec(f).bufpos:=0;
  592. end;
  593. Function ClosePipe(var F:text):cint;
  594. begin
  595. textrec(f).mode:=fmclosed;
  596. ClosePipe:=fpclose(textrec(f).handle);
  597. end;
  598. Function AssignPipe(var pipe_in,pipe_out:text):cint;
  599. {
  600. Sets up a pair of file variables, which act as a pipe. The first one can
  601. be read from, the second one can be written to.
  602. }
  603. var
  604. f_in,f_out : cint;
  605. begin
  606. if AssignPipe(f_in,f_out)=-1 then
  607. exit(-1);
  608. { Set up input }
  609. Assign(Pipe_in,'');
  610. Textrec(Pipe_in).Handle:=f_in;
  611. Textrec(Pipe_in).Mode:=fmInput;
  612. Textrec(Pipe_in).userdata[1]:=P_IN;
  613. TextRec(Pipe_in).OpenFunc:=@OpenPipe;
  614. TextRec(Pipe_in).InOutFunc:=@IOPipe;
  615. TextRec(Pipe_in).FlushFunc:=@FlushPipe;
  616. TextRec(Pipe_in).CloseFunc:=@ClosePipe;
  617. { Set up output }
  618. Assign(Pipe_out,'');
  619. Textrec(Pipe_out).Handle:=f_out;
  620. Textrec(Pipe_out).Mode:=fmOutput;
  621. Textrec(Pipe_out).userdata[1]:=P_OUT;
  622. TextRec(Pipe_out).OpenFunc:=@OpenPipe;
  623. TextRec(Pipe_out).InOutFunc:=@IOPipe;
  624. TextRec(Pipe_out).FlushFunc:=@FlushPipe;
  625. TextRec(Pipe_out).CloseFunc:=@ClosePipe;
  626. AssignPipe:=0;
  627. end;
  628. Function AssignPipe(var pipe_in,pipe_out:file):cint;
  629. {
  630. Sets up a pair of file variables, which act as a pipe. The first one can
  631. be read from, the second one can be written to.
  632. If the operation was unsuccesful,
  633. }
  634. var
  635. f_in,f_out : cint;
  636. begin
  637. if AssignPipe(f_in,f_out)=-1 then
  638. exit(-1);
  639. { Set up input }
  640. Assign(Pipe_in,'');
  641. Filerec(Pipe_in).Handle:=f_in;
  642. Filerec(Pipe_in).Mode:=fmInput;
  643. Filerec(Pipe_in).recsize:=1;
  644. Filerec(Pipe_in).userdata[1]:=P_IN;
  645. { Set up output }
  646. Assign(Pipe_out,'');
  647. Filerec(Pipe_out).Handle:=f_out;
  648. Filerec(Pipe_out).Mode:=fmoutput;
  649. Filerec(Pipe_out).recsize:=1;
  650. Filerec(Pipe_out).userdata[1]:=P_OUT;
  651. AssignPipe:=0;
  652. end;
  653. Function PCloseText(Var F:text):cint;
  654. {
  655. May not use @PClose due overloading
  656. }
  657. begin
  658. PCloseText:=PClose(f);
  659. end;
  660. function POpen(var F:text;const Prog:String;rw:char):cint;
  661. {
  662. Starts the program in 'Prog' and makes it's input or out put the
  663. other end of a pipe. If rw is 'w' or 'W', then whatever is written to
  664. F, will be read from stdin by the program in 'Prog'. The inverse is true
  665. for 'r' or 'R' : whatever the program in 'Prog' writes to stdout, can be
  666. read from 'f'.
  667. }
  668. var
  669. pipi,
  670. pipo : text;
  671. pid : pid_t;
  672. pl : ^cint;
  673. pp : ppchar;
  674. ret : cint;
  675. begin
  676. rw:=upcase(rw);
  677. if not (rw in ['R','W']) then
  678. begin
  679. FpSetErrno(ESysEnoent);
  680. exit(-1);
  681. end;
  682. if AssignPipe(pipi,pipo)=-1 Then
  683. Exit(-1);
  684. pid:=fpfork; // vfork in FreeBSD.
  685. if pid=-1 then
  686. begin
  687. close(pipi);
  688. close(pipo);
  689. exit(-1);
  690. end;
  691. if pid=0 then
  692. begin
  693. { We're in the child }
  694. if rw='W' then
  695. begin
  696. close(pipo);
  697. ret:=fpdup2(pipi,input);
  698. close(pipi);
  699. if ret=-1 then
  700. halt(127);
  701. end
  702. else
  703. begin
  704. close(pipi);
  705. ret:=fpdup2(pipo,output);
  706. close(pipo);
  707. if ret=-1 then
  708. halt(127);
  709. end;
  710. {$ifdef FPC_USE_FPEXEC}
  711. fpexecl('/bin/sh',['-c',Prog]);
  712. {$else}
  713. pp:=createshellargv(prog);
  714. fpExecve(pp^,pp,envp);
  715. {$endif}
  716. halt(127);
  717. end
  718. else
  719. begin
  720. { We're in the parent }
  721. if rw='W' then
  722. begin
  723. close(pipi);
  724. f:=pipo;
  725. textrec(f).bufptr:=@textrec(f).buffer;
  726. end
  727. else
  728. begin
  729. close(pipo);
  730. f:=pipi;
  731. textrec(f).bufptr:=@textrec(f).buffer;
  732. end;
  733. {Save the process ID - needed when closing }
  734. pl:=@(textrec(f).userdata[2]);
  735. pl^:=pid;
  736. textrec(f).closefunc:=@PCloseText;
  737. end;
  738. ret:=0;
  739. end;
  740. Function POpen(var F:file;const Prog:String;rw:char):cint;
  741. {
  742. Starts the program in 'Prog' and makes it's input or out put the
  743. other end of a pipe. If rw is 'w' or 'W', then whatever is written to
  744. F, will be read from stdin by the program in 'Prog'. The inverse is true
  745. for 'r' or 'R' : whatever the program in 'Prog' writes to stdout, can be
  746. read from 'f'.
  747. }
  748. var
  749. pipi,
  750. pipo : file;
  751. pid : cint;
  752. pl : ^cint;
  753. p,pp : ppchar;
  754. temp : string[255];
  755. ret : cint;
  756. begin
  757. rw:=upcase(rw);
  758. if not (rw in ['R','W']) then
  759. begin
  760. FpSetErrno(ESysEnoent);
  761. exit(-1);
  762. end;
  763. ret:=AssignPipe(pipi,pipo);
  764. if ret=-1 then
  765. exit(-1);
  766. pid:=fpfork;
  767. if pid=-1 then
  768. begin
  769. close(pipi);
  770. close(pipo);
  771. exit(-1);
  772. end;
  773. if pid=0 then
  774. begin
  775. { We're in the child }
  776. if rw='W' then
  777. begin
  778. close(pipo);
  779. ret:=fpdup2(filerec(pipi).handle,stdinputhandle);
  780. close(pipi);
  781. if ret=-1 then
  782. halt(127);
  783. end
  784. else
  785. begin
  786. close(pipi);
  787. ret:=fpdup2(filerec(pipo).handle,stdoutputhandle);
  788. close(pipo);
  789. if ret=1 then
  790. halt(127);
  791. end;
  792. {$ifdef FPC_USE_FPEXEC}
  793. fpexecl('/bin/sh',['-c',Prog]);
  794. {$else}
  795. getmem(pp,sizeof(pchar)*4);
  796. temp:='/bin/sh'#0'-c'#0+prog+#0;
  797. p:=pp;
  798. p^:=@temp[1];
  799. inc(p);
  800. p^:=@temp[9];
  801. inc(p);
  802. p^:=@temp[12];
  803. inc(p);
  804. p^:=Nil;
  805. fpExecve(ansistring('/bin/sh'),pp,envp);
  806. {$endif}
  807. halt(127);
  808. end
  809. else
  810. begin
  811. { We're in the parent }
  812. if rw='W' then
  813. begin
  814. close(pipi);
  815. f:=pipo;
  816. end
  817. else
  818. begin
  819. close(pipo);
  820. f:=pipi;
  821. end;
  822. {Save the process ID - needed when closing }
  823. pl:=@(filerec(f).userdata[2]);
  824. pl^:=pid;
  825. end;
  826. POpen:=0;
  827. end;
  828. Function AssignStream(Var StreamIn,Streamout:text;Const Prog:ansiString;const args : array of ansistring) : cint;
  829. {
  830. Starts the program in 'Prog' and makes its input and output the
  831. other end of two pipes, which are the stdin and stdout of a program
  832. specified in 'Prog'.
  833. streamout can be used to write to the program, streamin can be used to read
  834. the output of the program. See the following diagram :
  835. Parent Child
  836. STreamout --> Input
  837. Streamin <-- Output
  838. Return value is the process ID of the process being spawned, or -1 in case of failure.
  839. }
  840. var
  841. pipi,
  842. pipo : text;
  843. pid : cint;
  844. pl : ^cint;
  845. begin
  846. AssignStream:=-1;
  847. if AssignPipe(streamin,pipo)=-1 Then
  848. exit(-1);
  849. if AssignPipe(pipi,streamout)=-1 Then // shouldn't this close streamin and pipo?
  850. exit(-1);
  851. pid:=fpfork;
  852. if pid=-1 then
  853. begin
  854. close(pipi);
  855. close(pipo);
  856. close (streamin);
  857. close (streamout);
  858. exit;
  859. end;
  860. if pid=0 then
  861. begin
  862. { We're in the child }
  863. { Close what we don't need }
  864. close(streamout);
  865. close(streamin);
  866. if fpdup2(pipi,input)=-1 Then
  867. halt(127);
  868. close(pipi);
  869. If fpdup2(pipo,output)=-1 Then
  870. halt (127);
  871. close(pipo);
  872. fpExecl(Prog,args);
  873. halt(127);
  874. end
  875. else
  876. begin
  877. { we're in the parent}
  878. close(pipo);
  879. close(pipi);
  880. {Save the process ID - needed when closing }
  881. pl:=@(textrec(StreamIn).userdata[2]);
  882. pl^:=pid;
  883. textrec(StreamIn).closefunc:=@PCloseText;
  884. {Save the process ID - needed when closing }
  885. pl:=@(textrec(StreamOut).userdata[2]);
  886. pl^:=pid;
  887. textrec(StreamOut).closefunc:=@PCloseText;
  888. AssignStream:=Pid;
  889. end;
  890. end;
  891. Function AssignStream(Var StreamIn,Streamout,streamerr:text;Const Prog:ansiString;const args : array of ansistring) : cint;
  892. {
  893. Starts the program in 'prog' and makes its input, output and error output the
  894. other end of three pipes, which are the stdin, stdout and stderr of a program
  895. specified in 'prog'.
  896. StreamOut can be used to write to the program, StreamIn can be used to read
  897. the output of the program, StreamErr reads the error output of the program.
  898. See the following diagram :
  899. Parent Child
  900. StreamOut --> StdIn (input)
  901. StreamIn <-- StdOut (output)
  902. StreamErr <-- StdErr (error output)
  903. }
  904. var
  905. PipeIn, PipeOut, PipeErr: text;
  906. pid: cint;
  907. pl: ^cint;
  908. begin
  909. AssignStream := -1;
  910. // Assign pipes
  911. if AssignPipe(StreamIn, PipeOut)=-1 Then
  912. Exit(-1);
  913. If AssignPipe(StreamErr, PipeErr)=-1 Then
  914. begin
  915. Close(StreamIn);
  916. Close(PipeOut);
  917. exit(-1);
  918. end;
  919. if AssignPipe(PipeIn, StreamOut)=-1 Then
  920. begin
  921. Close(StreamIn);
  922. Close(PipeOut);
  923. Close(StreamErr);
  924. Close(PipeErr);
  925. exit(-1);
  926. end;
  927. // Fork
  928. pid := fpFork;
  929. if pid=-1 then begin
  930. Close(StreamIn);
  931. Close(PipeOut);
  932. Close(StreamErr);
  933. Close(PipeErr);
  934. Close(PipeIn);
  935. Close(StreamOut);
  936. exit(-1);
  937. end;
  938. if pid = 0 then begin
  939. // *** We are in the child ***
  940. // Close what we don not need
  941. Close(StreamOut);
  942. Close(StreamIn);
  943. Close(StreamErr);
  944. // Connect pipes
  945. if fpdup2(PipeIn, Input)=-1 Then
  946. Halt(127);
  947. Close(PipeIn);
  948. if fpdup2(PipeOut, Output)=-1 Then
  949. Halt(127);
  950. Close(PipeOut);
  951. if fpdup2(PipeErr, StdErr)=-1 Then
  952. Halt(127);
  953. Close(PipeErr);
  954. // Execute program
  955. fpExecl(Prog,args);
  956. Halt(127);
  957. end else begin
  958. // *** We are in the parent ***
  959. Close(PipeErr);
  960. Close(PipeOut);
  961. Close(PipeIn);
  962. // Save the process ID - needed when closing
  963. pl := @(TextRec(StreamIn).userdata[2]);
  964. pl^ := pid;
  965. TextRec(StreamIn).closefunc := @PCloseText;
  966. // Save the process ID - needed when closing
  967. pl := @(TextRec(StreamOut).userdata[2]);
  968. pl^ := pid;
  969. TextRec(StreamOut).closefunc := @PCloseText;
  970. // Save the process ID - needed when closing
  971. pl := @(TextRec(StreamErr).userdata[2]);
  972. pl^ := pid;
  973. TextRec(StreamErr).closefunc := @PCloseText;
  974. AssignStream := pid;
  975. end;
  976. end;
  977. {******************************************************************************
  978. General information calls
  979. ******************************************************************************}
  980. {$ifdef Linux}
  981. Function GetDomainName:String; { linux only!}
  982. // domainname is a glibc extension.
  983. {
  984. Get machines domain name. Returns empty string if not set.
  985. }
  986. Var
  987. Sysn : utsname;
  988. begin
  989. If fpUname(sysn)<>0 then
  990. getdomainname:=''
  991. else
  992. getdomainname:=strpas(@Sysn.domain[0]);
  993. end;
  994. {$endif}
  995. {$ifdef BSD}
  996. function intGetDomainName(Name:PChar; NameLen:Cint):cint;
  997. {$ifndef FPC_USE_LIBC}
  998. external name 'FPC_SYSC_GETDOMAINNAME';
  999. {$else FPC_USE_LIBC}
  1000. cdecl; external clib name 'getdomainname';
  1001. {$endif FPC_USE_LIBC}
  1002. Function GetDomainName:String; { linux only!}
  1003. // domainname is a glibc extension.
  1004. {
  1005. Get machines domain name. Returns empty string if not set.
  1006. }
  1007. begin
  1008. if intGetDomainName(@getdomainname[1],255)=-1 then
  1009. getdomainname:=''
  1010. else
  1011. getdomainname[0]:=chr(strlen(@getdomainname[1]));
  1012. end;
  1013. {$endif}
  1014. Function GetHostName:String;
  1015. {
  1016. Get machines name. Returns empty string if not set.
  1017. }
  1018. Var
  1019. Sysn : utsname;
  1020. begin
  1021. If fpuname(sysn)=-1 then
  1022. gethostname:=''
  1023. else
  1024. gethostname:=strpas(@Sysn.nodename[0]);
  1025. end;
  1026. {******************************************************************************
  1027. Signal handling calls
  1028. ******************************************************************************}
  1029. procedure SigRaise(sig:integer);
  1030. begin
  1031. fpKill(fpGetPid,Sig);
  1032. end;
  1033. {******************************************************************************
  1034. Utility calls
  1035. ******************************************************************************}
  1036. Function FSearch(const path:AnsiString;dirlist:Ansistring;CurrentDirStrategy:TFSearchOption):AnsiString;
  1037. {
  1038. Searches for a file 'path' in the list of direcories in 'dirlist'.
  1039. returns an empty string if not found. Wildcards are NOT allowed.
  1040. If dirlist is empty, it is set to '.'
  1041. This function tries to make FSearch use ansistrings, and decrease
  1042. stringhandling overhead at the same time.
  1043. }
  1044. Var
  1045. mydir,NewDir : ansistring;
  1046. p1 : cint;
  1047. Info : Stat;
  1048. i,j : cint;
  1049. p : pchar;
  1050. Begin
  1051. if CurrentDirStrategy=CurrentDirectoryFirst Then
  1052. Dirlist:='.:'+dirlist; {Make sure current dir is first to be searched.}
  1053. if CurrentDirStrategy=CurrentDirectoryLast Then
  1054. Dirlist:=dirlist+':.'; {Make sure current dir is last to be searched.}
  1055. {Replace ':' and ';' with #0}
  1056. for p1:=1 to length(dirlist) do
  1057. if (dirlist[p1]=':') or (dirlist[p1]=';') then
  1058. dirlist[p1]:=#0;
  1059. {Check for WildCards}
  1060. If (Pos('?',Path) <> 0) or (Pos('*',Path) <> 0) Then
  1061. FSearch:='' {No wildcards allowed in these things.}
  1062. Else
  1063. Begin
  1064. p:=pchar(dirlist);
  1065. i:=length(dirlist);
  1066. j:=1;
  1067. Repeat
  1068. mydir:=ansistring(p);
  1069. if (length(mydir)>0) and (mydir[length(mydir)]<>'/') then
  1070. mydir:=mydir+'/';
  1071. NewDir:=mydir+Path;
  1072. if (FpStat(NewDir,Info)>=0) and
  1073. (not fpS_ISDIR(Info.st_Mode)) then
  1074. Begin
  1075. If Pos('./',NewDir)=1 Then
  1076. Delete(NewDir,1,2);
  1077. {DOS strips off an initial .\}
  1078. End
  1079. Else
  1080. NewDir:='';
  1081. while (j<=i) and (p^<>#0) do begin inc(j); inc(p); end;
  1082. if p^=#0 then inc(p);
  1083. Until (j>=i) or (Length(NewDir) > 0);
  1084. FSearch:=NewDir;
  1085. End;
  1086. End;
  1087. Function FSearch(const path:AnsiString;dirlist:Ansistring):AnsiString;
  1088. Begin
  1089. FSearch:=FSearch(path,dirlist,CurrentDirectoryFirst);
  1090. End;
  1091. {--------------------------------
  1092. Stat.Mode Macro's
  1093. --------------------------------}
  1094. Initialization
  1095. {$IFNDEF DONT_READ_TIMEZONE}
  1096. InitLocalTime;
  1097. {$endif}
  1098. finalization
  1099. {$IFNDEF DONT_READ_TIMEZONE}
  1100. DoneLocalTime;
  1101. {$endif}
  1102. End.
  1103. {
  1104. $Log$
  1105. Revision 1.78 2004-11-21 11:28:21 peter
  1106. * fixed bootstrap with 1.0.10 and 1.9.4
  1107. Revision 1.77 2004/11/19 13:15:15 marco
  1108. * external rework. Mostly done.
  1109. Revision 1.76 2004/11/03 15:00:43 marco
  1110. * Pathstr eliminated
  1111. Revision 1.75 2004/10/30 20:55:54 marco
  1112. * unix interface cleanup
  1113. Revision 1.74 2004/07/18 14:54:42 jonas
  1114. * fixed BSD getdomainname for FPC_USE_LIBC
  1115. Revision 1.73 2004/07/18 11:27:54 marco
  1116. * small fix for BSD getdomainname. BSD version is based on Sysctl
  1117. Revision 1.72 2004/07/03 13:18:06 daniel
  1118. * Better fix.
  1119. Revision 1.71 2004/07/03 13:15:51 daniel
  1120. * Compilation fix in fsearch
  1121. Revision 1.70 2004/04/23 19:16:25 marco
  1122. * flock -> fpflock because of conflicting structure name
  1123. Revision 1.69 2004/04/22 17:17:13 peter
  1124. * x86-64 fixes
  1125. Revision 1.68 2004/03/04 22:15:17 marco
  1126. * UnixType changes. Please report problems to me.
  1127. Revision 1.66 2004/02/16 13:21:18 marco
  1128. * fpexec for popen
  1129. Revision 1.65 2004/02/14 21:12:14 marco
  1130. * provisorische fix voor Michael's problemen
  1131. Revision 1.64 2004/02/14 18:22:15 marco
  1132. * fpsystem, and some FPC_USE_LIBC fixes. (FreeBSD needs systypes.inc, also when FPC_USE_LIBC, it only contains types like statfs
  1133. Revision 1.63 2004/02/13 10:50:22 marco
  1134. * Hopefully last large changes to fpexec and friends.
  1135. - naming conventions changes from Michael.
  1136. - shell functions get alternative under ifdef.
  1137. - arraystring function moves to unixutil
  1138. - unixutil now regards quotes in stringtoppchar.
  1139. - sysutils/unix get executeprocess(ansi,array of ansi), and
  1140. both executeprocess functions are fixed
  1141. - Sysutils/win32 get executeprocess(ansi,array of ansi)
  1142. Revision 1.62 2004/02/12 16:20:58 marco
  1143. * currentpath stuff fixed for fsearch
  1144. Revision 1.61 2004/02/12 15:31:06 marco
  1145. * First version of fpexec change. Still under ifdef or silently overloaded
  1146. Revision 1.60 2004/01/23 08:11:18 jonas
  1147. * only include systypes.inc if FPC_USE_LIBC is not defined
  1148. Revision 1.59 2004/01/22 13:46:14 marco
  1149. bsd
  1150. Revision 1.58 2004/01/04 21:05:01 jonas
  1151. * declare C-library routines as external in libc so we generate proper
  1152. import entries for Darwin
  1153. Revision 1.57 2004/01/04 20:53:02 jonas
  1154. * don't use systypes if FPC_USE_LIBC is defined
  1155. Revision 1.56 2004/01/04 16:24:05 jonas
  1156. * fixed WaitProcess in case of SysEintr
  1157. Revision 1.55 2003/12/31 20:24:25 marco
  1158. * export statfs(pchar)
  1159. Revision 1.54 2003/12/30 15:43:20 marco
  1160. * linux now compiles with FPC_USE_LIBC
  1161. Revision 1.53 2003/12/30 12:24:01 marco
  1162. * FPC_USE_LIBC
  1163. Revision 1.52 2003/12/08 17:16:30 peter
  1164. * fsearch should only find files
  1165. Revision 1.51 2003/11/19 17:11:40 marco
  1166. * termio unit
  1167. Revision 1.50 2003/11/19 10:54:32 marco
  1168. * some simple restructures
  1169. Revision 1.49 2003/11/17 11:28:08 marco
  1170. * Clone moved to linux, + few small unit unix changes
  1171. Revision 1.48 2003/11/17 10:05:51 marco
  1172. * threads for FreeBSD. Not working tho
  1173. Revision 1.47 2003/11/14 17:30:14 marco
  1174. * weeehoo linuxerror is no more :-)
  1175. Revision 1.46 2003/11/14 16:44:48 marco
  1176. * stream functions converted to work without linuxerror
  1177. Revision 1.45 2003/11/13 18:44:06 marco
  1178. * small fi
  1179. Revision 1.44 2003/11/12 22:19:45 marco
  1180. * more linuxeror fixes
  1181. Revision 1.43 2003/11/03 09:42:28 marco
  1182. * Peter's Cardinal<->Longint fixes patch
  1183. Revision 1.42 2003/10/30 16:42:58 marco
  1184. * fixes for old syscall() convention removing
  1185. Revision 1.41 2003/10/12 19:40:43 marco
  1186. * ioctl fixes. IDE now starts, but
  1187. Revision 1.40 2003/09/29 14:36:06 peter
  1188. * fixed for stricter compiler
  1189. Revision 1.39 2003/09/27 12:51:33 peter
  1190. * fpISxxx macros renamed to C compliant fpS_ISxxx
  1191. Revision 1.38 2003/09/20 12:38:29 marco
  1192. * FCL now compiles for FreeBSD with new 1.1. Now Linux.
  1193. Revision 1.37 2003/09/17 19:07:44 marco
  1194. * more fixes for Unix<->unixutil
  1195. Revision 1.36 2003/09/17 17:30:46 marco
  1196. * Introduction of unixutil
  1197. Revision 1.35 2003/09/16 21:46:27 marco
  1198. * small fixes, checking things on linux
  1199. Revision 1.34 2003/09/16 20:52:24 marco
  1200. * small cleanups. Mostly killing of already commented code in unix etc
  1201. Revision 1.33 2003/09/16 16:13:56 marco
  1202. * fdset functions renamed to fp<posix name>
  1203. Revision 1.32 2003/09/15 20:08:49 marco
  1204. * small fixes. FreeBSD now cycles
  1205. Revision 1.31 2003/09/14 20:15:01 marco
  1206. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  1207. Revision 1.30 2003/07/08 21:23:24 peter
  1208. * sparc fixes
  1209. Revision 1.29 2003/05/30 19:58:40 marco
  1210. * Getting NetBSD/i386 to compile.
  1211. Revision 1.28 2003/05/29 19:16:16 marco
  1212. * fixed a small *BSD gotcha
  1213. Revision 1.27 2003/05/24 20:39:54 jonas
  1214. * fixed ExitCode translation in WaitProcess for Linux and Darwin (and
  1215. probably other BSD's as well)
  1216. Revision 1.26 2003/03/11 08:27:59 michael
  1217. * stringtoppchar should use tabs instead of backspace as delimiter
  1218. Revision 1.25 2002/12/18 16:50:39 marco
  1219. * Unix RTL generic parts. Linux working, *BSD will follow shortly
  1220. Revision 1.24 2002/09/07 16:01:28 peter
  1221. * old logs removed and tabs fixed
  1222. Revision 1.23 2002/08/06 13:30:46 sg
  1223. * replaced some Longints with Cardinals, to mach the C headers
  1224. * updated the termios record
  1225. Revision 1.22 2002/03/05 20:04:25 michael
  1226. + Patch from Sebastian for FCNTL call
  1227. Revision 1.21 2002/01/02 12:22:54 marco
  1228. * Removed ifdef arround getepoch.
  1229. }