Skip to content

Commit f8fbfb4

Browse files
claudethewilsonator
authored andcommitted
std.process: switch retryInterrupted to std.internal.retry.retryOnEINTR
Removes the local nested retryInterrupted template in spawnProcessPosix and switches its three call sites to the shared retryOnEINTR helper. Pure refactor — semantics are identical.
1 parent 5b2ff71 commit f8fbfb4

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

std/process.d

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,18 +1244,11 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
12441244
{
12451245
closePipeWriteEnds();
12461246

1247-
T retryInterrupted(T)(scope T delegate() syscall)
1248-
{
1249-
import core.stdc.errno : errno, EINTR;
1250-
T result;
1251-
do
1252-
result = syscall();
1253-
while (result == -1 && .errno == EINTR);
1254-
return result;
1255-
}
1247+
import std.internal.retry : retryOnEINTR;
12561248

12571249
auto status = InternalError.noerror;
1258-
auto readExecResult = retryInterrupted(() => core.sys.posix.unistd.read(forkPipe[0], &status, status.sizeof));
1250+
auto readExecResult = retryOnEINTR(
1251+
() => core.sys.posix.unistd.read(forkPipe[0], &status, status.sizeof));
12591252
// Save error number just in case if subsequent "waitpid" fails and overrides errno
12601253
immutable lastError = .errno;
12611254

@@ -1264,7 +1257,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
12641257
// Forked child exits right after creating second fork. So it should be safe to wait here.
12651258
import core.sys.posix.sys.wait : waitpid;
12661259
int waitResult;
1267-
retryInterrupted(() => waitpid(id, &waitResult, 0));
1260+
retryOnEINTR(() => waitpid(id, &waitResult, 0));
12681261
}
12691262

12701263
if (readExecResult == -1)
@@ -1274,7 +1267,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
12741267
if (status != InternalError.noerror)
12751268
{
12761269
int error;
1277-
readExecResult = retryInterrupted(() => read(forkPipe[0], &error, error.sizeof));
1270+
readExecResult = retryOnEINTR(() => read(forkPipe[0], &error, error.sizeof));
12781271
string errorMsg;
12791272
final switch (status)
12801273
{

0 commit comments

Comments
 (0)