unxfunc.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2000 by Marco van de Voort
  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. {$ifndef HAS_LIBC_PIPING}
  12. Function PClose(Var F:file) : cint;
  13. var
  14. pl : ^cint;
  15. res : cint;
  16. begin
  17. fpclose(filerec(F).Handle);
  18. { closed our side, Now wait for the other - this appears to be needed ?? }
  19. pl:=@(filerec(f).userdata[2]);
  20. fpwaitpid(pl^,@res,0);
  21. pclose:=res shr 8;
  22. end;
  23. Function PClose(Var F:text) :cint;
  24. var
  25. pl : pcint;
  26. res : cint;
  27. begin
  28. fpclose(Textrec(F).Handle);
  29. { closed our side, Now wait for the other - this appears to be needed ?? }
  30. pl:=@(textrec(f).userdata[2]);
  31. fpwaitpid(pl^,@res,0);
  32. pclose:=res shr 8;
  33. end;{$ENDIF}
  34. // can't have oldfpccall here, linux doesn't need it.
  35. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  36. {
  37. Sets up a pair of file variables, which act as a pipe. The first one can
  38. be read from, the second one can be written to.
  39. If the operation was unsuccesful, linuxerror is set.
  40. }
  41. var
  42. ret : cint;
  43. errn : cint;
  44. {$ifdef FPC_USE_LIBC}
  45. fdis : array[0..1] of cint;
  46. {$endif}
  47. begin
  48. {$ifndef FPC_USE_LIBC}
  49. ret:=intAssignPipe(pipe_in,pipe_out,errn);
  50. if ret=-1 Then
  51. fpseterrno(errn);
  52. {$ELSE}
  53. fdis[0]:=pipe_in;
  54. fdis[1]:=pipe_out;
  55. ret:=pipe(fdis);
  56. pipe_in:=fdis[0];
  57. pipe_out:=fdis[1];
  58. {$ENDIF}
  59. AssignPipe:=ret;
  60. end;