| 1 | |
| 2 | |
| 3 | |
| 4 | package osutil |
| 5 | |
| 6 | import ( |
| 7 | "io/fs" |
| 8 | "syscall" |
| 9 | ) |
| 10 | |
| 11 | |
| 12 | const UnixPathMax = 108 |
| 13 | |
| 14 | |
| 15 | type Stat struct { |
| 16 | Uid uint32 |
| 17 | Gid uint32 |
| 18 | } |
| 19 | |
| 20 | func SysStat(fi fs.FileInfo) (Stat, bool) { |
| 21 | stat, ok := fi.Sys().(*syscall.Stat_t) |
| 22 | return Stat{Uid: stat.Uid, Gid: stat.Gid}, ok |
| 23 | } |
| 24 | |
| 25 | |
| 26 | const SigInt = Signal(syscall.SIGINT) |
| 27 | |
| 28 | |
| 29 | const SigTerm = Signal(syscall.SIGTERM) |
| 30 | |
| 31 | |
| 32 | const SigKill = Signal(syscall.SIGKILL) |
| 33 | |
| 34 | type Signal syscall.Signal |
| 35 | |
| 36 | func SysKill(pid int, sig Signal) error { |
| 37 | return syscall.Kill(pid, syscall.Signal(sig)) |
| 38 | } |