mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 13:40:11 +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.stdio;
|
||||||
import core.sys.posix.stdlib;
|
import core.sys.posix.stdlib;
|
||||||
import core.sys.posix.unistd;
|
import core.sys.posix.unistd;
|
||||||
|
import core.stdc.errno;
|
||||||
|
|
||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
|
@ -1229,13 +1230,19 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
|
||||||
OutBuffer buffer;
|
OutBuffer buffer;
|
||||||
ubyte[1024] tmp = void;
|
ubyte[1024] tmp = void;
|
||||||
ptrdiff_t nread;
|
ptrdiff_t nread;
|
||||||
while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0)
|
for(;;)
|
||||||
buffer.write(tmp[0 .. nread]);
|
|
||||||
|
|
||||||
if (nread == -1)
|
|
||||||
{
|
{
|
||||||
perror("read");
|
while ((nread = read(pipefd[0], tmp.ptr, tmp.length)) > 0)
|
||||||
return STATUS_FAILED;
|
buffer.write(tmp[0 .. nread]);
|
||||||
|
|
||||||
|
if (nread == -1)
|
||||||
|
{
|
||||||
|
if(errno == EINTR) continue;
|
||||||
|
|
||||||
|
perror("read");
|
||||||
|
return STATUS_FAILED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue