From 2abe4619922ed57a9b8a51e1bb4946566cf61f29 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 12 Jul 2016 20:05:11 -0700 Subject: [PATCH] Refactor to use GetUserFromPid --- .../commands/management/Process.cs | 2 +- .../CoreCLR/CorePsPlatform.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 13aabd84d7..1a622ed288 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -867,7 +867,7 @@ namespace Microsoft.PowerShell.Commands { string userName = null; #if LINUX - userName = Platform.NonWindowsGetFileOwner("/proc/" + process.Id); + userName = Platform.NonWindowsGetUserFromPid(process.Id); #else IntPtr tokenUserInfo = IntPtr.Zero; IntPtr processTokenHandler = IntPtr.Zero; diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index fc735c4700..eb9d3b2624 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -354,11 +354,11 @@ namespace System.Management.Automation } } - internal static string NonWindowsGetFileOwner(string path) + internal static string NonWindowsGetUserFromPid(int path) { if (!IsWindows) { - return LinuxPlatform.GetFileOwner(path); + return LinuxPlatform.GetUserFromPid(path); } else { @@ -752,9 +752,9 @@ namespace System.Management.Automation return Native.FollowSymLink(path); } - public static string GetFileOwner(string path) + public static string GetUserFromPid(int pid) { - return Native.GetFileOwner(path); + return Native.GetUserFromPid(pid); } [StructLayout(LayoutKind.Sequential)] @@ -828,7 +828,7 @@ namespace System.Management.Automation [DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)] [return: MarshalAs(UnmanagedType.LPStr)] - internal static extern string GetFileOwner([MarshalAs(UnmanagedType.LPStr)]string filePath); + internal static extern string GetUserFromPid(int pid); } }