mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Retry read() syscall on EINTR (#21188)
The read() syscall can get interrupted by a signal, in which case you can just retry the read call instead of failing with an error. This is most noticeable if you run the compiler in a debugger.
This commit is contained in:
parent
74cdfed9d6
commit
93b0317cc3
1 changed files with 13 additions and 6 deletions
|
@ -39,6 +39,7 @@ version (Posix)
|
|||
import core.sys.posix.stdio;
|
||||
import core.sys.posix.stdlib;
|
||||
import core.sys.posix.unistd;
|
||||
import core.stdc.errno;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
|
@ -1229,13 +1230,19 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
|
|||
OutBuffer buffer;
|
||||
ubyte[1024] tmp = void;
|
||||
ptrdiff_t nread;
|
||||
while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0)
|
||||
buffer.write(tmp[0 .. nread]);
|
||||
|
||||
if (nread == -1)
|
||||
for(;;)
|
||||
{
|
||||
perror("read");
|
||||
return STATUS_FAILED;
|
||||
while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0)
|
||||
buffer.write(tmp[0 .. nread]);
|
||||
|
||||
if (nread == -1)
|
||||
{
|
||||
if(errno == EINTR) continue;
|
||||
|
||||
perror("read");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int status;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue