Files
oldlinux-files/Minix/2.0.0/wwwman/man2/write.2.html
2024-02-19 00:21:39 -05:00

124 lines
3.2 KiB
HTML

<HTML>
<HEAD>
<TITLE>write(2)</TITLE>
</HEAD>
<BODY>
<H1>write(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
write - write output
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;unistd.h&gt;</STRONG>
<STRONG>ssize_t</STRONG> <STRONG>write(int</STRONG> <EM>d</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*</STRONG><EM>buf</EM><STRONG>,</STRONG> <STRONG>size_t</STRONG> <EM>nbytes</EM><STRONG>)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
<STRONG>Write</STRONG> attempts to write <EM>nbytes</EM> of data to the object referenced by the
descriptor <EM>d</EM> from the buffer pointed to by <EM>buf</EM>.
On objects capable of seeking, the <STRONG>write</STRONG> starts at a position given by
the pointer associated with <EM>d</EM>, see <STRONG><A HREF="../man2/lseek.2.html">lseek(2)</A></STRONG>. Upon return from <STRONG>write</STRONG>, the
pointer is incremented by the number of bytes actually written.
Objects that are not capable of seeking always write from the current
position. The value of the pointer associated with such an object is
undefined.
When using non-blocking I/O on objects such as TCP/IP channels that are
subject to flow control, <STRONG>write</STRONG> may write fewer bytes than requested; the
return value must be noted, and the remainder of the operation should be
retried when possible.
</PRE>
<H2>RETURN VALUE</H2><PRE>
Upon successful completion the number of bytes actually written is
returned. Otherwise a -1 is returned and the global variable <STRONG>errno</STRONG> is
set to indicate the error.
</PRE>
<H2>ERRORS</H2><PRE>
<STRONG>Write</STRONG> will fail and the file pointer will remain unchanged if one or more
of the following are true:
[EBADF] <EM>D</EM> is not a valid descriptor open for writing.
[EPIPE] An attempt is made to write to a pipe that is not open for
reading by any process.
[EPIPE] An attempt is made to write to a TCP channel that is not
connected to a peer socket.
[EFBIG] An attempt was made to write a file that exceeds the
process's file size limit or the maximum file size.
[EFAULT] Part of the data to be written to the file points outside
the process's allocated address space.
[ENOSPC] There is no free space remaining on the file system
containing the file.
[EIO] An I/O error occurred while reading from or writing to the
file system.
[EAGAIN] The file was marked for non-blocking I/O, and no data
could be written immediately.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man2/fcntl.2.html">fcntl(2)</A></STRONG>, <STRONG><A HREF="../man2/lseek.2.html">lseek(2)</A></STRONG>, <STRONG><A HREF="../man2/open.2.html">open(2)</A></STRONG>, <STRONG><A HREF="../man2/pipe.2.html">pipe(2)</A></STRONG>, <STRONG><A HREF="../man2/read.2.html">read(2)</A></STRONG>.
</PRE>
</BODY>
</HTML>