May 29, 2023
https://issues.dlang.org/show_bug.cgi?id=23943

          Issue ID: 23943
           Summary: `execute` causes interrupted system call inside LLDB
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody@puremagic.com
          Reporter: doob@me.com

If I run some code that uses `std.process.execute` inside LLDB it will result in an exception thrown: "Interrupted system call". It does not occur when running the program by itself, only when running inside LLDB.

Steps to reproduce:

$ dmd --version
DMD64 D Compiler v2.103.1
Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
written by Walter Bright
$ cat main.d
void main()
{
    import std.process;
    execute(["ls"]);
}
$ dmd main.d
$ ./main
$ echo $?
0
$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) r
Process 40798 launched: 'main' (x86_64)

std.exception.ErrnoException@std/stdio.d(1166): Enforcement failed (Interrupted
system call)
----------------
??:? @safe noreturn
std.exception.bailOut!(std.exception.ErrnoException).bailOut(immutable(char)[],
ulong, scope const(char)[]) [0x10003c988]
??:? @safe bool
std.exception.enforce!(std.exception.ErrnoException).enforce!(bool).enforce(bool,
lazy const(char)[], immutable(char)[], ulong) [0x10003c9f3]
??:? @safe ubyte[] std.stdio.File.rawRead!(ubyte).rawRead(ubyte[])
[0x1000439d6]
??:? void std.stdio.File.ByChunkImpl.prime() [0x100042788]
??:? ref std.stdio.File.ByChunkImpl
std.stdio.File.ByChunkImpl.__ctor(std.stdio.File, ubyte[]) [0x10004293b]
??:? ref std.stdio.File.ByChunkImpl
std.stdio.File.ByChunkImpl.__ctor(std.stdio.File, ulong) [0x10004280d]
??:? std.stdio.File.ByChunkImpl std.stdio.File.byChunk(ulong) [0x100042c5b]
??:? @trusted std.typecons.Tuple!(int, "status", immutable(char)[],
"output").Tuple std.process.executeImpl!(std.process.pipeProcess,
const(char[])[]).executeImpl(const(char[])[],
const(immutable(char)[][immutable(char)[]]), std.process.Config, ulong, scope
const(char)[]) [0x10004091a]
??:? @safe std.typecons.Tuple!(int, "status", immutable(char)[],
"output").Tuple std.process.execute(scope const(char[])[],
const(immutable(char)[][immutable(char)[]]), std.process.Config, ulong, scope
const(char)[]) [0x10003fbbe]
??:? _Dmain [0x10000127d]
Process 40798 exited with status = 1 (0x00000001)
(lldb)

Most of the times when I run the program the exception is thrown, but not always. I tried both using DMD and LDC. Both running ARM64 and x86-64 (through Rosetta).

--