From a6c6d5a5a983aabe10d3062e56db5f546247c850 Mon Sep 17 00:00:00 2001
From: Giampaolo Rodola <g.rodola@gmail.com>
Date: Sun, 1 Oct 2023 11:29:29 -0700
Subject: [PATCH] fix send_signal()

---
 psutil/__init__.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/psutil/__init__.py b/psutil/__init__.py
index 6e7be6391f..5a5a20606a 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -1227,6 +1227,9 @@ def send_signal(self, sig):
             self._send_signal(sig)
         else:  # pragma: no cover
             self._raise_if_pid_reused()
+            if sig != signal.SIGTERM and not self.is_running():
+                msg = "process no longer exists"
+                raise NoSuchProcess(self.pid, self._name, msg=msg)
             self._proc.send_signal(sig)
 
     def suspend(self):