4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-18 23:12:15 +08:00

Cygwin: pipe: Fix handling of EPIPE and SIGPIPE in raw_write().

This commit is contained in:
Takashi Yano 2021-09-14 20:59:08 +09:00 committed by Corinna Vinschen
parent e4e4537979
commit a217fa98fd

View File

@ -407,6 +407,13 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
if (!len)
return 0;
if (reader_closed ())
{
set_errno (EPIPE);
raise (SIGPIPE);
return -1;
}
if (len <= pipe_buf_size)
chunk = len;
else if (is_nonblocking ())
@ -475,7 +482,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
CancelIo (get_handle ());
set_errno (EPIPE);
raise (SIGPIPE);
break;
goto out;
}
else
cygwait (select_sem, 10);
@ -527,6 +534,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
if (nbytes_now == 0)
break;
}
out:
if (evt)
CloseHandle (evt);
if (status == STATUS_THREAD_SIGNALED && nbytes == 0)