Skip to content

Commit

Permalink
use more readable variable aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 21, 2024
1 parent 0c0dd59 commit 60b79fc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,9 @@ def connections(self, kind="inet"):
def _send_signal(self, sig):
assert not self.pid < 0, self.pid
self._raise_if_pid_reused()
if self.pid == 0:

pid, ppid, name = self.pid, self._ppid, self._name
if pid == 0:
# see "man 2 kill"
msg = (
"preventing sending signal to process with PID 0 as it "
Expand All @@ -1259,18 +1261,17 @@ def _send_signal(self, sig):
)
raise ValueError(msg)
try:
os.kill(self.pid, sig)
os.kill(pid, sig)
except ProcessLookupError as err:
if OPENBSD and pid_exists(self.pid):
if OPENBSD and pid_exists(pid):
# We do this because os.kill() lies in case of
# zombie processes.
ppid = self._ppid
raise ZombieProcess(self.pid, self._name, ppid) from err
raise ZombieProcess(pid, name, ppid) from err
else:
self._gone = True
raise NoSuchProcess(self.pid, self._name) from err
raise NoSuchProcess(pid, name) from err
except PermissionError as err:
raise AccessDenied(self.pid, self._name) from err
raise AccessDenied(pid, name) from err

def send_signal(self, sig):
"""Send a signal *sig* to process pre-emptively checking
Expand Down

0 comments on commit 60b79fc

Please sign in to comment.