Don't display a warning when the binfmt process doesn't have a controlling terminal (#13176)
Some checks are pending
Build documentation / DeployDocs (push) Waiting to run

This commit is contained in:
Blue 2025-06-23 16:24:10 -07:00 committed by GitHub
parent 902848b76b
commit c1d6ad1d15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -678,12 +678,19 @@ Return Value:
//
// Ensure that stdin represents the foreground process group.
// N.B. It's possible that standard file descriptors point to tty while the process
// has no controlling terminal (in case its parent called setsid() without opening a new terminal for instance).
// See https://github.com/microsoft/WSL/issues/13173.
//
auto processGroup = tcgetpgrp(0);
if (processGroup < 0)
{
LOG_STDERR("tcgetpgrp failed");
if (errno != ENOTTY)
{
LOG_STDERR("tcgetpgrp failed");
}
return;
}

View file

@ -6119,5 +6119,16 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
VERIFY_ARE_EQUAL(err, L"");
}
// Validate that calling the binfmt interpreter with tty fd's but not controlling terminal doesn't display a warning.
// See https://github.com/microsoft/WSL/issues/13173.
TEST_METHOD(SetSidNoWarning)
{
auto [out, err] =
LxsstuLaunchWslAndCaptureOutput(L"socat - 'EXEC:setsid --wait cmd.exe /c echo OK',pty,setsid,ctty,stderr");
VERIFY_ARE_EQUAL(out, L"OK\r\r\n");
VERIFY_ARE_EQUAL(err, L"");
}
}; // namespace UnitTests
} // namespace UnitTests