write() system call blocking?

write() system call blocking?

Post by David R Maz » Wed, 28 Feb 1996 04:00:00



Hi,

I have a process which is blocking on a write() system
call to a fifo (named pipe) which is read by another process.

Under what circumstances could this happen?

I am running SunOS (BSD) 4.1.3U1.

Thanks in advance,

Dave Mazik

 
 
 

write() system call blocking?

Post by Geoff Cla » Thu, 07 Mar 1996 04:00:00




>>I have a process which is blocking on a write() system
>>call to a fifo (named pipe) which is read by another process.
>>Under what circumstances could this happen?
>    If the fifo is not open for reading by another process, and
>the write-side is opened with O_NDELAY and O_NONBLOCK clear, then the
>write will block.

Only if the writing process also has the fifo open for reading.

If the fifo is not open for reading at all, then the write() will
generate a SIGPIPE (or if SIGPIPE is being ignored it will fail with
errno=EPIPE).
--

UniSoft Limited, London, England.

 
 
 

1. Question on writing c program implement cp function using UNIX system calls - read, write, etc.

I need to write a c program that will perform like the cp command in UNIX
and copy one file to another. I need to use the UNIX system calls read(),
write(), open(), close(). I know how to open the source file for read access
and destination file for write access with open(), but I am unsure of how to
use read() and write().

I know read takes my file descriptor (fd) of the source file I opened as its
1st arguement. For the second, I need to put those bytes in some sort of
buffer right? Could I just write them directly to the destination file
instead of storing into a buffer? Well if I have to make a buffer for input
I read in I do this:

c = (char *) calloc(100, sizeof(char));

Is that right? If I do this will it work for all files whether they are
binary or ascii files?

The 3rd arg of read() takes in how many  bytes to read, how do I tell it to
read in the entire source file?

So for read, this is what I have so far: read(fd, c, ????) where fd is my
source file descriptor and c as define above.

As for write, I have: write(fd2, ???, ???) where fd2 is the file descriptor
of my destination file. How do I specify it to write what I read from the
input source file and write all of those bytes inputted? Thanks for any
help.

2. Installation help: CD driver not found?

3. Need help writing C program using UNIX system calls (read, write, etc) that copies files

4. How to compile for dual processor system?

5. How can I stop a call to write() blocking my interupts???

6. Xsun goes mad

7. How I could add a new system call to linux or modify a system calls

8. Nameservice for a Subdomain

9. How to use open system call in a new system call

10. "Interrupted system call" at "low level" - system calls

11. Can a send() system call on a UDP connection block?

12. tricky system call question, non-blocking connect()

13. 5.0 rc2: incoming call blocks system