Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -3881,6 +3881,7 @@ version (linux)
@system unittest
{
import core.atomic : atomicLoad, atomicStore;
import core.sys.posix.poll : poll, pollfd, POLLIN;
import core.sys.posix.pthread : pthread_kill;
import core.sys.posix.signal : SA_RESTART, SIGUSR1, sigaction, sigaction_t,
sigemptyset;
Expand Down Expand Up @@ -3921,7 +3922,17 @@ version (linux)
// Drain the pipe so the blocked write can make progress and complete.
ubyte[4096] buf;
while (!atomicLoad(done))
read(p.readEnd.fileno, buf.ptr, buf.length);
{
pollfd pfd =
{
fd : p.readEnd.fileno,
events : POLLIN,
revents : 0
};
int ret = poll(&pfd, 1, 100); // 100ms timeout
if (ret > 0 && (pfd.revents & POLLIN))
read(p.readEnd.fileno, buf.ptr, buf.length);
}
t.join();

assert(!atomicLoad(threw),
Expand Down
Loading