package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"syscall"
)
func main() {
files, err := ioutil.ReadDir("/proc/1/fd")
if err != nil {
log.Fatal(err)
}
for _, f := range files {
var path = "/proc/" + "/1/" + "/fd/" + f.Name()
var _, _ = os.Readlink(path)
//fmt.Println(lnkPath)
var stat syscall.Stat_t
err = syscall.Stat(path, &stat)
fmt.Println(stat.Mode)
typ := stat.Mode & syscall.S_IFMT
if typ == syscall.S_IFIFO{
fmt.Println("pipe")
}
if typ == syscall.S_IFCHR {
}
if typ == syscall.S_IFLNK {
}
if typ == syscall.S_IFSOCK {
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)