浏览文件
alive_windows.go
17 行 · 425 B历史下载| 1 | package cli |
| 2 | |
| 3 | import "golang.org/x/sys/windows" |
| 4 | |
| 5 | // alive reports whether the process pid exists and has not exited. |
| 6 | func alive(pid int) bool { |
| 7 | h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) |
| 8 | if err != nil { |
| 9 | return false |
| 10 | } |
| 11 | defer windows.CloseHandle(h) |
| 12 | var code uint32 |
| 13 | if windows.GetExitCodeProcess(h, &code) != nil { |
| 14 | return false |
| 15 | } |
| 16 | return code == 259 // STILL_ACTIVE |
| 17 | } |

