unxfunc.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. This file is part of the Free Component Library (FCL)
  3. Copyright (c) 1999-2000 by Peter Vreman
  4. Darwin temporary pclose/assignpipe implementation
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Function PClose(Var F:file) : cint;
  12. var
  13. pl : ^cint;
  14. res: cint;
  15. begin
  16. repeat
  17. res:=fpclose(filerec(F).Handle);
  18. until (res<>-1) or (fpgeterrno<>ESysEINTR);
  19. { closed our side, Now wait for the other - this appears to be needed ?? }
  20. pl:=@(filerec(f).userdata[2]);
  21. pclose := WaitProcess(pl^);
  22. end;
  23. Function PClose(Var F:text) :cint;
  24. var
  25. pl : ^cint;
  26. res : cint;
  27. begin
  28. repeat
  29. res:=fpclose(Textrec(F).Handle);
  30. until (res<>-1) or (fpgeterrno<>ESysEINTR);
  31. { closed our side, Now wait for the other - this appears to be needed ?? }
  32. pl:=@(textrec(f).userdata[2]);
  33. pclose:= WaitProcess(pl^);
  34. end;
  35. // can't have oldfpccall here, linux doesn't need it.
  36. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  37. {
  38. Sets up a pair of file variables, which act as a pipe. The first one can
  39. be read from, the second one can be written to.
  40. If the operation was unsuccesful, linuxerror is set.
  41. }
  42. var
  43. ret : longint;
  44. fdis : array[0..1] of cint;
  45. begin
  46. fdis[0]:=pipe_in;
  47. fdis[1]:=pipe_out;
  48. ret:=pipe(fdis);
  49. pipe_in:=fdis[0];
  50. pipe_out:=fdis[1];
  51. AssignPipe:=ret;
  52. end;