Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions doc/changelog.d/4293.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check access process on windows
3 changes: 3 additions & 0 deletions src/ansys/mapdl/core/cli/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,16 @@ def _can_access_process(proc):
True if we can safely access and kill the process
"""
import getpass
import platform

import psutil

try:
# Check if we can access basic process info and if it belongs to current user
current_user = getpass.getuser()
process_user = proc.username()
if platform.system() == "Windows" and "\\" in process_user:
return current_user == process_user.split("\\")[-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should check the domain then too... but I am not sure if that is even the logical thing to do.

return process_user == current_user
except (psutil.AccessDenied, psutil.NoSuchProcess):
# Cannot access process or process doesn't exist
Expand Down
Loading