unxfunc.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2000 by Marco van de Voort
  5. member of the Free Pascal development team.
  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. {$ifndef HAS_LIBC_PIPING}
  13. Function PClose(Var F:file) : cint;
  14. var
  15. pl : ^cint;
  16. res : cint;
  17. begin
  18. fpclose(filerec(F).Handle);
  19. { closed our side, Now wait for the other - this appears to be needed ?? }
  20. pl:=@(filerec(f).userdata[2]);
  21. fpwaitpid(pl^,@res,0);
  22. pclose:=res shr 8;
  23. end;
  24. Function PClose(Var F:text) :cint;
  25. var
  26. pl : ^longint;
  27. res : longint;
  28. begin
  29. fpclose(Textrec(F).Handle);
  30. { closed our side, Now wait for the other - this appears to be needed ?? }
  31. pl:=@(textrec(f).userdata[2]);
  32. fpwaitpid(pl^,@res,0);
  33. pclose:=res shr 8;
  34. end;
  35. {$ENDIF}
  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. errn : cint;
  45. {$ifdef FPC_USE_LIBC}
  46. fdis : array[0..1] of cint;
  47. {$endif}
  48. begin
  49. {$ifndef FPC_USE_LIBC}
  50. ret:=intAssignPipe(pipe_in,pipe_out,errn);
  51. if ret=-1 Then
  52. fpseterrno(errn);
  53. {$ELSE}
  54. fdis[0]:=pipe_in;
  55. fdis[1]:=pipe_out;
  56. ret:=pipe(fdis);
  57. pipe_in:=fdis[0];
  58. pipe_out:=fdis[1];
  59. {$ENDIF}
  60. AssignPipe:=ret;
  61. end;
  62. {
  63. $Log$
  64. Revision 1.2 2005-02-14 17:13:22 peter
  65. * truncate log
  66. Revision 1.1 2005/02/13 21:47:56 peter
  67. * include file cleanup part 2
  68. Revision 1.1 2005/02/13 20:01:37 peter
  69. * include file cleanup
  70. }