Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Detect *BSDs as supporting libc as well. #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/Mono.WebServer.FastCgi/Sockets/UnmanagedSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,33 @@ public object AsyncState {
static UnmanagedSocket ()
{
try {
string os = File.ReadAllText("/proc/sys/kernel/ostype");
supports_libc = os.StartsWith ("Linux");
string uname;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
var p = new System.Diagnostics.Process();

p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "uname";

p.Start();

uname = p.StandardOutput.ReadToEnd();
p.WaitForExit();
if (uname == null)
uname = "";
uname = uname.Trim().ToLower();

supports_libc = uname.StartsWith("linux") ||
uname.StartsWith("freebsd") ||
uname.StartsWith("netbsd") ||
uname.StartsWith("openbsd");
} catch {
uname = "";
}
if (uname == "") {
string os = File.ReadAllText("/proc/sys/kernel/ostype");
supports_libc = os.StartsWith ("Linux");
}
} catch {
}
}
Expand Down