Cygwin: FIFO: synchronize the blocking mode of a writer's pipe
The blocking mode of the Windows pipe underlying a writer is set to match that of the writer itself when the latter is opened. Define fhandler_fifo::fcntl to keep the pipe and the writer in sync if the blocking mode is changed via fcntl.
This commit is contained in:
		| @@ -1294,6 +1294,7 @@ public: | ||||
|   int open (int, mode_t); | ||||
|   off_t lseek (off_t offset, int whence); | ||||
|   int close (); | ||||
|   int fcntl (int cmd, intptr_t); | ||||
|   int dup (fhandler_base *child, int); | ||||
|   bool isfifo () const { return true; } | ||||
|   void set_close_on_exec (bool val); | ||||
|   | ||||
| @@ -891,6 +891,22 @@ fhandler_fifo::close () | ||||
|   return fhandler_base::close () || ret; | ||||
| } | ||||
|  | ||||
| /* If we're a writer, keep the nonblocking state of the windows pipe | ||||
|    in sync with our nonblocking state. */ | ||||
| int | ||||
| fhandler_fifo::fcntl (int cmd, intptr_t arg) | ||||
| { | ||||
|   if (cmd != F_SETFL || !writer) | ||||
|     return fhandler_base::fcntl (cmd, arg); | ||||
|  | ||||
|   const bool was_nonblocking = is_nonblocking (); | ||||
|   int res = fhandler_base::fcntl (cmd, arg); | ||||
|   const bool now_nonblocking = is_nonblocking (); | ||||
|   if (now_nonblocking != was_nonblocking) | ||||
|     set_pipe_non_blocking (get_handle (), now_nonblocking); | ||||
|   return res; | ||||
| } | ||||
|  | ||||
| int | ||||
| fhandler_fifo::dup (fhandler_base *child, int flags) | ||||
| { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user