Re: Problems with FIFO open in non-blocking mode?

1999-09-06 Thread Andrew Gierth

 "Alex" == Alex Povolotsky [EMAIL PROTECTED] writes:

 Alex  if ((control = open("STATUS",O_WRONLY|O_NONBLOCK))0) {

 Alex fails to run (STATUS is pre-created FIFO file) with error
 Alex "Device not configured", which seems kinda odd for me.

 Alex However, when FIFO is opened with O_RDWR and O_NONBLOCK, every
 Alex attempt to select(2) its handler for writing doesn't wait until
 Alex someone opens FIFO for reading, but instead FIFO is ready to
 Alex write at every select.

 Alex Is it a bug or a feature?

Both are features.

The behaviour of open() in the first case is required by standards. In
the second case, the fact that the FIFO has been opened O_RDWR means
that it _is_ ready for writing, and select() is correctly returning
the fact.

-- 
Andrew.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Problems with FIFO open in non-blocking mode?

1999-09-06 Thread Zhihui Zhang


On Mon, 6 Sep 1999, Alex Povolotsky wrote:

 Hello!
 
 The following program
 
 #include stdio.h
 #include fcntl.h
 
 main() {
   int control;
   if ((control = open("STATUS",O_WRONLY|O_NONBLOCK))0) {
   perror("Could not open STATUS ");
   exit(1);
   }
   printf("STATUS ready\n");
   close(control);
   return(0);
 }
 
 fails to run (STATUS is pre-created FIFO file) with error "Device not
 configured", which seems kinda odd for me.
 
 However, when FIFO is opened with O_RDWR and O_NONBLOCK, every attempt 
 to select(2) its handler for writing doesn't wait until someone opens
 FIFO for reading, but instead FIFO is ready to write at every select.
 
 Is it a bug or a feature?
 

I answered a similar question some time ago.  You can search the mailing
list archive for this.  Basically, you need to read the "Advanced Unix
Programming Environment" by Stevens.  I can not remember every details
right now.  The "device not configured" error is expected. 

-Zhihui



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Problems with FIFO open in non-blocking mode?

1999-09-06 Thread Andrew Gierth
 Alex == Alex Povolotsky tark...@asteroid.svib.ru writes:

 Alex  if ((control = open(STATUS,O_WRONLY|O_NONBLOCK))0) {

 Alex fails to run (STATUS is pre-created FIFO file) with error
 Alex Device not configured, which seems kinda odd for me.

 Alex However, when FIFO is opened with O_RDWR and O_NONBLOCK, every
 Alex attempt to select(2) its handler for writing doesn't wait until
 Alex someone opens FIFO for reading, but instead FIFO is ready to
 Alex write at every select.

 Alex Is it a bug or a feature?

Both are features.

The behaviour of open() in the first case is required by standards. In
the second case, the fact that the FIFO has been opened O_RDWR means
that it _is_ ready for writing, and select() is correctly returning
the fact.

-- 
Andrew.


To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-hackers in the body of the message



Re: Problems with FIFO open in non-blocking mode?

1999-09-06 Thread Zhihui Zhang

On Mon, 6 Sep 1999, Alex Povolotsky wrote:

 Hello!
 
 The following program
 
 #include stdio.h
 #include fcntl.h
 
 main() {
   int control;
   if ((control = open(STATUS,O_WRONLY|O_NONBLOCK))0) {
   perror(Could not open STATUS );
   exit(1);
   }
   printf(STATUS ready\n);
   close(control);
   return(0);
 }
 
 fails to run (STATUS is pre-created FIFO file) with error Device not
 configured, which seems kinda odd for me.
 
 However, when FIFO is opened with O_RDWR and O_NONBLOCK, every attempt 
 to select(2) its handler for writing doesn't wait until someone opens
 FIFO for reading, but instead FIFO is ready to write at every select.
 
 Is it a bug or a feature?
 

I answered a similar question some time ago.  You can search the mailing
list archive for this.  Basically, you need to read the Advanced Unix
Programming Environment by Stevens.  I can not remember every details
right now.  The device not configured error is expected. 

-Zhihui



To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-hackers in the body of the message