Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ read(2) — Ultrix-11 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(2)

dup(2)

fcntl(2)

ioctl(2)

open(2)

pipe(2)

read(2)

NAME

read − read from file

SYNTAX

#include <fcntl.h>

int read(fildes, buffer, nbytes)
int fildes;
char *buffer;
unsigned nbytes;

DESCRIPTION

A file descriptor is a word returned from a successful creat, dup, open, or pipe call.  The specified buffer is the location of nbytes contiguous bytes into which the input will be placed.  It is not guaranteed that all nbytes bytes will be read.  For example, if the file refers to a typewriter, at most one line will be returned.  In any event, the number of characters read is returned. 

When attempting to read from an empty pipe or FIFO:

•If O_NDELAY is set, the read will return a 0. 

•If O_NDELAY is clear, the read will block until data is written to the file or the file is no longer open for writing. 

When attempting to read a file associated with a character special file that has no data currently available:

•If O_NDELAY is set, the read will return a 0. 

•If O_NDELAY is clear, the read will block until data becomes available. 

If the returned value is 0, then end-of-file has been reached. 

DIAGNOSTICS

The read call will fail if:

[EBADF] The specified fildes is not a valid file descriptor open for reading. 

[EFAULT] The specified buf points outside the process’s allocated address space. 

[EFAULT] The specified address either is odd or, when dealing with character special files, is out of range. 

[EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal. 

[ENXIO] The /dev/mem address specified is illegal. 

[ETPL] Either the tape tape position was lost, or the tape unit went offline during a read. 

[EWOULDBLOCK]
The process would hang waiting for input (when mode is set to interrupt on each character input).

ASSEMBLER

(read = 3.) 
(file descriptor in r0)
sys read; buffer; nbytes
(byte count in r0)

SEE ALSO

creat(2), dup(2), fcntl(2), ioctl(2), open(2), pipe(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026