runtime: Why System.Diagnostics.Process.MainWindowTitle returns empty string on Linux?
System.Diagnostics.Process.MainWindowTitle is empty for all processes on Linux, even when the application has root rights. Tested on Ubuntu 19.10 64bit with .NET Core 3.1 console application.
Repro
sudo ./ConsoleApp2
class Program
{
static void Main(string[] args)
{
var procs = Process.GetProcesses();
foreach (var proc in procs)
{
Console.WriteLine($"Process: {proc.ProcessName}, MainWindowTitle: {(string.IsNullOrEmpty(proc.MainWindowTitle) ? "<EMPTY>" : proc.MainWindowTitle)}");
}
}
}
Result:

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (8 by maintainers)
My conclusion from this is that if you get an empty string, there shouldn’t be a main window. I don’t believe this is “following suit with the docs”. I put in a PR for the docs.
Then you should update the docs to reflect that? https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.mainwindowtitle?view=netcore-3.1