<div dir="ltr"><div>Hi,</div><div><br></div><div>I've noticed that we leak file descriptors, since we don't use O_CLOEXEC when opening files.</div><div>I've changed lldb_utility::PseudoTerminal, debugserver version of it and lldb_private::File to set it while opening by default.</div>
<div><br></div><div>This can be disabled by defining:</div><div>LLDB_DISABLE_O_CLOEXEC and LLDB_DISABLE_DUPFD_CLOEXEC, currently not integrated with any filesystem.</div><div>It also should compile if O_CLOEXEC and F_DUPFD_CLOEXEC aren't defined, and give compilation warning.</div>
<div><br></div><div>Also added new File open option:</div><div>eOpenOptionInheritOnExecPosixFD that makes it fallback to old behavior, however in whole code base it was not required, and could be removed...<br></div><div>
<br></div><div>I went pretty carefully through fork()/exec() and posix_spawn() codepaths to ensure that everything is OK, and it looked it is, but might have missed something.</div><div>None of them required changes, from what I have noticed, since use dup2 or posix_spawnattr_add*.</div>
<div><br></div><div>If any of your out of tree code needs to be adjusted, PseudoTerminal::Fork looks like good example how to pass fd without leaking.</div><div><br></div><div>I've tested linux amd64 and haven't noticed any regressions comparing to trunk, but some tests fail in non-deterministic way, so could mask it...</div>
<div><br></div><div>Most notably:</div><div><div>TestStepNoDebug.py </div><div>TestCommandRegex.py</div></div><div><br></div><div>Managed to make them fail with and without the patch running in separate.</div><div><br></div>
<div>I've possibly broke debugserver when WITH_SPRINGBOARD is defined for launch code path.</div><div>I don't know SBSLaunchApplicationForDebugging semantics, and have no idea how to fix it, beside disabling it for PseudoTerminal if this option is defined.</div>
<div>Those changes are not strictly required for debugserver yet I have made them for completeness.</div><div><br></div><div>Both raw diff and git patch are attached.</div><div><br></div>Please test attached, and report back if any problems are noticed.<div>
<br></div><div>Cheers,</div><div>/Piotr</div><div><br></div><div>PS.</div><div>@Greg, sorry that it took longer than I thought it will.</div></div>