MCPcopy Create free account
hub / github.com/chromedp/chromedp / killProcessesUsing

Function killProcessesUsing

remote/keepopen_linux_test.go:24–47  ·  view source on GitHub ↗

killProcessesUsing kills the processes that have the user data directory dir in their command line.

(dir string)

Source from the content-addressed store, hash-verified

22// killProcessesUsing kills the processes that have the user data directory dir
23// in their command line.
24func killProcessesUsing(dir string) {
25 want := "--user-data-dir=" + dir
26 entries, err := os.ReadDir("/proc")
27 if err != nil {
28 return
29 }
30 self := os.Getpid()
31 for _, entry := range entries {
32 pid, err := strconv.Atoi(entry.Name())
33 if err != nil || pid == self {
34 continue
35 }
36 cmdline, err := os.ReadFile("/proc/" + entry.Name() + "/cmdline")
37 if err != nil {
38 continue
39 }
40 for arg := range bytes.SplitSeq(cmdline, []byte{0}) {
41 if string(arg) == want {
42 syscall.Kill(pid, syscall.SIGKILL)
43 break
44 }
45 }
46 }
47}

Callers 1

killProfileProcessesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected