unixfunc.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.1 2005-02-13 20:01:37 peter
  65. * include file cleanup
  66. Revision 1.20 2004/04/23 19:16:24 marco
  67. * flock -> fpflock because of conflicting structure name
  68. Revision 1.19 2004/03/04 22:15:16 marco
  69. * UnixType changes. Please report problems to me.
  70. Revision 1.18 2004/01/01 17:07:21 marco
  71. * few small freebsd fixes backported from debugging linux
  72. Revision 1.17 2003/12/30 12:32:30 marco
  73. *** empty log message ***
  74. Revision 1.16 2003/11/19 17:11:40 marco
  75. * termio unit
  76. Revision 1.15 2003/11/19 10:12:02 marco
  77. * more cleanups
  78. Revision 1.14 2003/11/17 10:05:51 marco
  79. * threads for FreeBSD. Not working tho
  80. Revision 1.13 2003/11/14 16:21:59 marco
  81. * linuxerror elimination
  82. Revision 1.12 2003/11/09 12:00:16 marco
  83. * pipe fix
  84. Revision 1.11 2003/09/20 12:38:29 marco
  85. * FCL now compiles for FreeBSD with new 1.1. Now Linux.
  86. Revision 1.10 2003/09/15 20:08:49 marco
  87. * small fixes. FreeBSD now cycles
  88. Revision 1.9 2003/09/15 07:09:58 marco
  89. * small fixes, round 1
  90. Revision 1.8 2003/09/14 20:15:01 marco
  91. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  92. Revision 1.7 2003/01/05 19:02:29 marco
  93. * Should now work with baseunx. (gmake all works)
  94. Revision 1.6 2002/10/18 12:19:59 marco
  95. * Fixes to get the generic *BSD RTL compiling again + fixes for thread
  96. support. Still problems left in fexpand. (inoutres?) Therefore fixed
  97. sysposix not yet commited
  98. Revision 1.5 2002/09/07 16:01:18 peter
  99. * old logs removed and tabs fixed
  100. Revision 1.4 2002/05/06 09:35:09 marco
  101. * Some stuff from 1.0.x ported
  102. }