gopass/pkg/clipboard/kill_ps.go
Dominik Schulz 71861e4a8b
chore: Update golangci-lint (#3287)
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2025-11-12 21:09:26 +01:00

26 lines
593 B
Go

//go:build darwin || (freebsd && amd64) || linux || solaris || windows || (freebsd && arm) || (freebsd && arm64)
package clipboard
import (
"fmt"
ps "github.com/mitchellh/go-ps"
)
// killPrecedessors will kill any previous "gopass unclip" invocations to avoid
// erasing the clipboard prematurely in case the the same content is copied to
// the clipboard repeatedly.
func killPrecedessors() error {
procs, err := ps.Processes()
if err != nil {
return fmt.Errorf("failed to list processes: %w", err)
}
for _, proc := range procs {
walkFn(proc.Pid(), killProc)
}
return nil
}