Check if a process exists in go way

后端 未结 7 1899
甜味超标
甜味超标 2020-12-31 02:29

If I have the PID of a process, is os.FindProcess enough to test for the existing of the process? I mean if it returns err can I assume that it\'s terminated (o

7条回答
  •  渐次进展
    2020-12-31 02:32

    On unix like systems (linux, freebsd, etc) os.FindProcess will never return an error. I don't know what happens on Windows. This means you won't know if the PID is correct until you try to use the *os.Process for something.

    You can look at the code here.

提交回复
热议问题