xref: /csrg-svn/lib/libc/sys/write.2 (revision 20053)
Copyright (c) 1980 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)write.2 4.1 (Berkeley) 05/09/85

WRITE 2
C 4
NAME
write - write on a file
SYNOPSIS
 write(fildes, buffer, nbytes)  char *buffer; 
DESCRIPTION
A file descriptor is a word returned from a successful open, creat, dup, or pipe (2) call.

Buffer is the address of nbytes contiguous bytes which are written on the output file. The number of characters actually written is returned. It should be regarded as an error if this is not the same as requested.

Writes which are multiples of 1024 characters long and begin on a 1024-byte boundary in the file are more efficient than any others.

Write s to the control terminal by a process which is not in the process group of the termainl and which is not ignoring or holding SIGTTOU signals cause the writer's process group to receive a SIGTTOU signal (See jobs (3) and the description of the LTOSTOP option in tty (4) for details).

On some systems write clears the set-user-id bit on a file. This prevents penetration of system security by a user who \*(lqcaptures\*(rq a writeable set-user-id file owned by the super-user.

"SEE ALSO"
creat(2), open(2), pipe(2)
DIAGNOSTICS
Returns -1 on error: bad descriptor, buffer address, or count; physical I/O errors.
"ASSEMBLER (PDP-11)"
(write = 4.)

(file descriptor in r0)

sys write; buffer; nbytes

(byte count in r0)

BUGS
It would be nice to be able to call write and have the call return with an error indication if there was no buffer space for the written data, rather than blocking the process.

Processes which have been orphaned by their parents and have been inherited by init (8) never receive SIGTTOU signals. Output by such a process is permitted even when they are not in the process group of the control terminal.