fd_write

Gamma: Version 4.0
Prev |  | Next

# `fd_write`

`fd_write` -- writes a buffer or string to a file identified by a file descriptor.

## Syntax

    fd_write (fd, buffer|string, length?, offset?)

## Arguments

`fd`

  A file descriptor as returned from `fd_open`.

`buffer`|`string`

  A buffer or string to write to the file.

`length`

  An integer specifying the length of the buffer or string.

`offset`

  An integer specifying the position in the file to begin writing the buffer or string.

## Returns

The number of bytes actually written to the file, or -1 on failure and the errno is set.

## Description

This function writes a buffer or string to the specified file.

When an error occurs, the following errnos are possible:

- EAGAIN The O_NONBLOCK flag is set for the `fd` and the process would be delayed in the write operation.

- EBADF The passed `fd` is invalid or not open for writing.

- EFBIG File is too big.

- EINTR Write was interrupted by a signal.

- EINVAL iovcnt was less than or equal to 0, or greater than UIO_MAXIOV.

- EIO Physical IO error.

- ENOSPC No free space remaining on drive.

- EPIPE Attempt to write to a pipe (or FIFO) that is not open for write. SIGPIPE is also sent to process.

## Example

        Gamma> x = fd_open("/fd/ser1",O_RDWR);
        4
        Gamma> fd_write(x,"hello\n");
        6
        Gamma> fd_close(x);
        t

## See Also

`fd_close`, `fd_open`, `fd_read`, `ser_setup`, Referencing Files

Prev | Home | Next
`fd_to_file` | Up | `fileno`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.