|
|
@ -75,11 +75,16 @@ func getTerminalMap() (map[uint64]string, error) {
|
|
|
|
// https://github.com/python/cpython/blob/08ff4369afca84587b1c82034af4e9f64caddbf2/Lib/posixpath.py#L186-L216
|
|
|
|
// https://github.com/python/cpython/blob/08ff4369afca84587b1c82034af4e9f64caddbf2/Lib/posixpath.py#L186-L216
|
|
|
|
// https://docs.python.org/3/library/os.path.html#os.path.ismount
|
|
|
|
// https://docs.python.org/3/library/os.path.html#os.path.ismount
|
|
|
|
func isMount(path string) bool {
|
|
|
|
func isMount(path string) bool {
|
|
|
|
var stat1 unix.Stat_t
|
|
|
|
// Check symlinkness with os.Lstat; unix.DT_LNK is not portable
|
|
|
|
if err := unix.Lstat(path, &stat1); err != nil {
|
|
|
|
fileInfo, err := os.Lstat(path)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if fileInfo.Mode() & os.ModeSymlink != 0 {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if stat1.Mode == unix.DT_LNK {
|
|
|
|
var stat1 unix.Stat_t
|
|
|
|
|
|
|
|
if err := unix.Lstat(path, &stat1); err != nil {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parent := filepath.Join(path, "..")
|
|
|
|
parent := filepath.Join(path, "..")
|
|
|
@ -98,6 +103,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if isMount(common.HostProc()) { // if /<HOST_PROC>/proc exists and is mounted, check if /<HOST_PROC>/proc/<PID> folder exists
|
|
|
|
if isMount(common.HostProc()) { // if /<HOST_PROC>/proc exists and is mounted, check if /<HOST_PROC>/proc/<PID> folder exists
|
|
|
|
_, err := os.Stat(common.HostProc(strconv.Itoa(int(pid))))
|
|
|
|
_, err := os.Stat(common.HostProc(strconv.Itoa(int(pid))))
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|