diff --git a/process/process_posix.go b/process/process_posix.go index caa9d3f7c..96c5e065c 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -108,6 +108,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { if err != nil { return false, err } + defer proc.Release() if isMount(common.HostProcWithContext(ctx)) { // if //proc exists and is mounted, check if //proc/ folder exists _, err := os.Stat(common.HostProcWithContext(ctx, strconv.Itoa(int(pid)))) @@ -144,6 +145,7 @@ func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) if err != nil { return err } + defer process.Release() err = process.Signal(sig) if err != nil { diff --git a/process/process_windows.go b/process/process_windows.go index b00c671e9..012886d6c 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -817,6 +817,7 @@ func (p *Process) KillWithContext(ctx context.Context) error { if err != nil { return err } + defer process.Release() return process.Kill() }