This is an appendix to Understanding Unix/Linux Programming written for people interested in Ada programming on POSIX systems.

Connection Control: Studying stty

Section 5.2.2, page 141

Devices and System Calls

For example, code to read from a magnetic tape could look like this:

   Tape       : File_Descriptor;
   Position   : IO_Offset;
   Buffer     : IO_Buffer (1 .. 1024);
   Bytes_Read : IO_Count;
   Tape := Open (Name => "/dev/tape",
                 Mode => Read_Only);
   Seek (File   => Tape,
         Offset => 4096,
         Result => Position);
   Read (File   => Tape,
         Buffer => Buffer,
         Last   => Bytes_Read);
   Close (File => Tape);

Some Devices Do No Support All File Operations

Terminals support Read and Write, but not Seek. Why is that?

Section 5.2.5, pages 143-144

This simple version of write does not send the Message from ... introduction and requires the filename for the terminal (the ttyname), not the username of the other person: write0.adb

Section 5.4.1, page 147

   Mode    : File_Mode;
   Options : Open_Option_Set;
   Get_File_Control (File    => File,
                     Mode    => Mode,
                     Options => Options);
   Options := Options + File_Synchronized;
   Set_File_Control (File    => File,
                     Options => Options);


Go to next chapter.

Collected examples:
Based on:
Understanding Unix/Linux Programming, Bruce Molay, ISBN 0-13-008396-8.
Main page:
Written by:
Jacob Sparre Andersen.
Latest update:
19th of April, 2008