From cf4ecc3eafd7c43fb9313c6c50974021bab53ffd Mon Sep 17 00:00:00 2001 From: Ron Federman <73110295+RonFed@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:42:46 +0200 Subject: [PATCH] Reset the /proc offset after a failed attempt to find pid (#681) * Reset the /proc offset after a failed attempt to fiind pid * Update changelog --- CHANGELOG.md | 1 + internal/pkg/process/discover.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6245b178..8d6f145b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http - Close `proc` file when done discovering PID. ([#649](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/649)) - Use `debug` packages to parse Go and modules' versions. ([#653](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/653)) - Clean up warn in otelglobal `SetStatus()` when grabbing the status code. ([#675](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/675)) +- Reset `proc` offset after a failed iteration. ([#681](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/681)) - Avoid using runtime.NumCPU to get the number of CPUs on the system before remote mmap ([#680](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/680)) ## [v0.10.1-alpha] - 2024-01-10 diff --git a/internal/pkg/process/discover.go b/internal/pkg/process/discover.go index 0ea160b72..b4ab1d3bc 100644 --- a/internal/pkg/process/discover.go +++ b/internal/pkg/process/discover.go @@ -82,6 +82,12 @@ func (a *Analyzer) DiscoverProcessID(target *TargetArgs) (int, error) { } else { a.logger.Error(err, "error while searching for process", "exe_path", target.ExePath) } + + // Reset the file offset for next iteration + _, err = proc.Seek(0, 0) + if err != nil { + return 0, err + } } } }