unixfunc.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. $Id$
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1999-2000 by Peter Vreman
  5. Darwin temporary pclose/assignpipe implementation
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Function PClose(Var F:file) : cint;
  13. var
  14. pl : ^cint;
  15. begin
  16. fpclose(filerec(F).Handle);
  17. { closed our side, Now wait for the other - this appears to be needed ?? }
  18. pl:=@(filerec(f).userdata[2]);
  19. pclose := WaitProcess(pl^);
  20. end;
  21. Function PClose(Var F:text) :cint;
  22. var
  23. pl : ^longint;
  24. begin
  25. fpclose(Textrec(F).Handle);
  26. { closed our side, Now wait for the other - this appears to be needed ?? }
  27. pl:=@(textrec(f).userdata[2]);
  28. pclose:= WaitProcess(pl^);
  29. end;
  30. // can't have oldfpccall here, linux doesn't need it.
  31. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  32. {
  33. Sets up a pair of file variables, which act as a pipe. The first one can
  34. be read from, the second one can be written to.
  35. If the operation was unsuccesful, linuxerror is set.
  36. }
  37. var
  38. ret : longint;
  39. errn : cint;
  40. fdis : array[0..1] of cint;
  41. begin
  42. fdis[0]:=pipe_in;
  43. fdis[1]:=pipe_out;
  44. ret:=pipe(fdis);
  45. pipe_in:=fdis[0];
  46. pipe_out:=fdis[1];
  47. AssignPipe:=ret;
  48. end;
  49. {
  50. $Log$
  51. Revision 1.1 2005-02-13 20:01:37 peter
  52. * include file cleanup
  53. Revision 1.3 2004/07/01 18:34:53 jonas
  54. * adapted second pclose as well
  55. Revision 1.2 2004/07/01 18:28:15 jonas
  56. * fixed returning of proper exit status after pclose
  57. Revision 1.1 2004/01/04 20:05:38 jonas
  58. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  59. Several non-essential units are still missing, but make cycle works
  60. }