read
lees van een bestandindicator
1. read.2.man
Manpage of READ
READ
Section: Linux Programmeurs Handleiding (2)Updated: July 12, 1997
Index Return to Main Contents
NAAM
read - lees van een bestandindicatorOVERZICHT
#include <unistd.h> ssize_t read(int bi, void *buf, size_t tel);
BESCHRIJVING
read() Probeert tot aan tel bytes van bestandsindicator bi in te lezen naar de buffer buf.Als tel nul is geeft read() nul terug zonder andere gevolgen. Als tel groter is dan SSIZE_MAX, is het resultaat onbepaald.
EIND WAARDE
Bij success wordt het aantal gelezen bytes teruggegeven (nul betekend einde van het bestand); de positie in het bestand wordt met dit aantal vooruitgezet. Het is niet fout als dat aantal kleiner is dan het gevraagde aantal bytes, dat kan bijvoorbeeld gebeuren als er minder bytes voorhanden zijn op dat ogenblik (wellicht omdat we dicht bij eind-van-bestand zijn, omdat we van een pijp {pipe} lezen, of van een terminal, of omdat read() onderbroken werd door een signaal). Bij falen wordt -1 teruggegeven, en errno wordt naar behoren gezet. In dit geval is het onbepaald gelaten of de plaats in het bestand (als die bestaat) veranderd.FOUTEN
- EINTR
- {onderbroken} De aanroep werd onderbroken door een signaal voordat er gegevens werden gelezen.
- EAGAIN
- {opnieuw} Niet-blokkerende In/Uit werd gekozen met O_NONBLOCK {niet blokkeren} maar er stonden niet onmiddelijk gegevens klaar om gelezen te worden.
- EIO
- {In/Uit} In/Uit fout. Dit gebeurd bijvoorbeeld als een proces uit een achtergrond-proces-groep probeert van zijn controlerende tty te lezen en, òf het negeert/blokkeert SIGTTIN, òf zijn proces-groep is verweesd {orphaned}. Het kan ook optreden als er een laag-niveau In/Uit fout is terwijl er van schijf of tape gelezen wordt.
- EISDIR
- {is dir} bi wijst naar een directorie
- EBADF
- {slecht bestand} bi Is geen geldige bestandsindicator, of is niet open voor lezen.
- EINVAL
- {ongeldig} bi wijst naar iets dat ongeschikt is om van te lezen
- EFAULT
- {fout} buf Ligt buiten de door u toegankelijke adres ruimte.
Andere fouten kunnen ontstaan, afhankelijk van waar bi mee verbonden is. POSIX Staat een read() die onderbroken wordt na het lezen van enige gegevens toe om -1 terug te geven (met errno gezet naar EINTR); of om het aantal gelezen bytes terug te geven.
VOLDOET AAN
SVr4, SVID, AT&T, POSIX, X/OPEN, BSD 4.3BEPERKINGEN
Bij NFS bestandsystemen zal het lezen van kleine hoeveelheden gegevens de tijdtempel alleen de eerste keer veranderen, volgende aanroepen laten de tijdtempel onveranderd. Dit wordt veroorzaakt door cliënt-kant bufferen van bestand-kenmerken: de meeste -zo niet alle- NFS cliënten laten het bijwerken van de `atime' {toegangstijd} aan de server over; als een lees-opdracht dan genoeg heeft aan de cliënt-kant buffer vind er geen lees-opdracht plaats naar de server en blijft de atime dus onveranderd. UNIX Gedrag kan verkregen worden door het kenmerken bufferen in de cliënt uit te schakelen, maar dat zal in de meeste situaties de last op de server flink vergroten, en zijn uitvoering nadelig beïnvloeden.ZIE OOK
close(2) {sluiten}, fcntl(2) {manipuleer bi}, ioctl(2) {in/uit-manipuleren}, lseek(2) {zoek}, readdir(2) {lees dir}, readlink(2) {lees koppeling}, select(2) {kies}, write(2) {schrijf}, fread(3) {lees}VERTALING
Alles wat tussen `{'..`}' staat is aanvullende vertaling, en hoort niet bij de originele handleiding. Deze handleiding uit manpages-dev 1.34 werd vertaald door JHBoersema. Email naar <manpages-nl@nl.linux.org>.$Id: read.2,v 1.1 2001/03/28 21:06:42 joostvb Exp $
Index
This document was created by man2html using the manual pages.
Time: 23:25:41 GMT, July 09, 2008
2. read.9.man
Manpage of read
read
Section: Tcl Built-In Commands (n)Updated: 8.1
Index Return to Main Contents
NAME
read - Read from a channelSYNOPSIS
read ?-nonewline? channelIdread channelId numChars
DESCRIPTION
In the first form, the read command reads all of the data from channelId up to the end of the file. If the -nonewline switch is specified then the last character of the file is discarded if it is a newline. In the second form, the extra argument specifies how many characters to read. Exactly that many characters will be read and returned, unless there are fewer than numChars left in the file; in this case all the remaining characters are returned. If the channel is configured to use a multi-byte encoding, then the number of characters read may not be the same as the number of bytes read.
ChannelId must be an identifier for an open channel such as the Tcl standard input channel (stdin), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input.
If channelId is in nonblocking mode, the command may not read as many characters as requested: once all available input has been read, the command will return the data that is available rather than blocking for more input. If the channel is configured to use a multi-byte encoding, then there may actually be some bytes remaining in the internal buffers that do not form a complete character. These bytes will not be returned until a complete character is available or end-of-file is reached. The -nonewline switch is ignored if the command returns before reaching the end of the file.
Read translates end-of-line sequences in the input into newline characters according to the -translation option for the channel. See the fconfigure manual entry for a discussion on ways in which fconfigure will alter input.
USE WITH SERIAL PORTS
For most applications a channel connected to a serial port should be configured to be nonblocking: fconfigure channelId -blocking 0. Then read behaves much like described above. Care must be taken when using read on blocking serial ports:
- read channelId numChars
- In this form read blocks until numChars have been received from the serial port.
- read channelId
- In this form read blocks until the reception of the end-of-file character, see fconfigure -eofchar. If there no end-of-file character has been configured for the channel, then read will block forever.
EXAMPLE
This example code reads a file all at once, and splits it into a list, with each line in the file corresponding to an element in the list:-
set fl [open /proc/meminfo] set data [read $fl] close $fl set lines [split $data
]
SEE ALSO
file(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3)KEYWORDS
blocking, channel, end of line, end of file, nonblocking, read, translation, encoding
Index
This document was created by man2html using the manual pages.
Time: 23:25:42 GMT, July 09, 2008





