[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'oldlinux' (#rtl)

AssignPipe

Create a set of pipe file handlers

Declaration

Source position: line 0

function AssignPipe(

  var pipe_in: LongInt;

  var pipe_out: LongInt

):Boolean;

function AssignPipe(

  var pipe_in: text;

  var pipe_out: text

):Boolean;

function AssignPipe(

  var pipe_in: file;

  var pipe_out: file

):Boolean;

Description

AssignePipe creates a pipe, i.e. two file objects, one for input, one for output. What is written to Pipe_out, can be read from Pipe_in.

This call is overloaded. The in and out pipe can take three forms: an typed or untyped file, a text file or a file descriptor.

If a text file is passed then reading and writing from/to the pipe can be done through the usual Readln(Pipe_in,...) and Writeln(Pipe_out,...) procedures.

The function returns True if everything went succesfully, False otherwise.

Errors

In case the function fails and returns False, LinuxError is used to report errors:

sys_emfile
Too many file descriptors for this process.
sys_enfile
The system file table is full.

See also

POpen

  

Pipe file to standard input/output of program

MkFifo

  

Create FIFO (named pipe) in file system

Example

Program Example36;

{ Program to demonstrate the AssignPipe function. }

Uses oldlinux;

Var pipi,pipo : Text;
    s : String;

begin
  Writeln ('Assigning Pipes.');
  If Not assignpipe(pipi,pipo) then
    Writeln('Error assigning pipes !',LinuxError);
  Writeln ('Writing to pipe, and flushing.');
  Writeln (pipo,'This is a textstring');close(pipo);
  Writeln ('Reading from pipe.');
  While not eof(pipi) do
    begin
    Readln (pipi,s);
    Writeln ('Read from pipe : ',s);
    end;
  close (pipi);
  writeln ('Closed pipes.');
  writeln
end.
The latest version of this document can be found at lazarus-ccr.sourceforge.net.