2
0

unxfunc.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  4. member of the Free Pascal development team.
  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 AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  12. {
  13. Sets up a pair of file variables, which act as a pipe. The first one can
  14. be read from, the second one can be written to.
  15. If the operation was unsuccesful, linuxerror is set.
  16. }
  17. var
  18. pip : tfildes;
  19. begin
  20. {$ifdef FPC_USE_LIBC}
  21. assignpipe:=pipe(pip);
  22. {$else}
  23. assignPipe:=fppipe(pip);
  24. {$endif}
  25. pipe_in:=pip[0];
  26. pipe_out:=pip[1];
  27. end;
  28. Function PClose(Var F:text) :cint;
  29. var
  30. pl : pcint;
  31. res : cint;
  32. pid : cint;
  33. begin
  34. fpclose(Textrec(F).Handle);
  35. { closed our side, Now wait for the other - this appears to be needed ?? }
  36. pl:=pcint(@(textrec(f).userdata[2]));
  37. { avoid alignment error on sparc }
  38. move(pl^,pid,sizeof(pid));
  39. fpwaitpid(pid,@res,0);
  40. pclose:=res shr 8;
  41. end;
  42. Function PClose(Var F:file) : cint;
  43. var
  44. pl : ^cint;
  45. res : cint;
  46. pid : cint;
  47. begin
  48. fpclose(filerec(F).Handle);
  49. { closed our side, Now wait for the other - this appears to be needed ?? }
  50. pl:=pcint(@(filerec(f).userdata[2]));
  51. { avoid alignment error on sparc }
  52. move(pl^,pid,sizeof(pid));
  53. fpwaitpid(pid,@res,0);
  54. pclose:=res shr 8;
  55. end;