Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsRunningWithContext not independent of wall clock #1802

Open
1 task done
joshiste opened this issue Feb 26, 2025 · 1 comment
Open
1 task done

IsRunningWithContext not independent of wall clock #1802

joshiste opened this issue Feb 26, 2025 · 1 comment

Comments

@joshiste
Copy link
Contributor

joshiste commented Feb 26, 2025

Describe the bug
When the system time is adjusted, Process.IsRunning() may return false, despite the process being running.

The process's create time is used for this, but it's converted to wall time when being read, so if the system clock was changed in between (e.g 1h in the future), Process.IsRunning() returns false.

Expected behavior
IsRunning() returns true for running processes even after system time change.

Environment (please complete the following information):

  • Linux: [paste contents of /etc/os-release and the result of uname -a]
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Linux ip-**-*-**-***.eu-central-1.compute.internal 5.10.233-224.894.amzn2.x86_64 #1 SMP Mon Jan 27 16:52:48 UTC 2025 x86_64 GNU/Linux
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
joshiste added a commit to steadybit/extension-jvm that referenced this issue Feb 26, 2025
As the gopsutil library will report running processes as not running
(see shirou/gopsutil#1802)
we need to workaround that.
@shirou
Copy link
Owner

shirou commented Mar 4, 2025

When process.EnableBootTimeCache() is not used (which is the default), if the boot time changes, the createTime also changes, causing IsRunning to return false. I see.

The IsRunning() method mimics the behavior of psutil, where the pid is uniquely identified by combining pid and create_time. Since psutil caches create_time, this issue doesn’t occur there.

With this in mind, I’m starting to think it might be a good idea for gopsutil to cache createTime as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants