fix: release process after os.FindProcess()

pull/1716/head
NitroCao 6 months ago
parent 7ec134321c
commit fcdd277935

@ -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 /<HOST_PROC>/proc exists and is mounted, check if /<HOST_PROC>/proc/<PID> 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 {

@ -817,6 +817,7 @@ func (p *Process) KillWithContext(ctx context.Context) error {
if err != nil {
return err
}
defer process.Release()
return process.Kill()
}

Loading…
Cancel
Save