diff --git a/cmd/enit/main.go b/cmd/enit/main.go index 5cdd46f..1184a91 100644 --- a/cmd/enit/main.go +++ b/cmd/enit/main.go @@ -12,6 +12,7 @@ import ( "strings" "syscall" "time" + "unsafe" ) // Build-time variables @@ -22,6 +23,12 @@ var runstatedir = "/var/run/" var serviceManagerPid int func main() { + // Set Process Name + err := setProcessName() + if err != nil { + log.Printf("Could not set process name! Error: %s", err) + } + // Parse flags printVersion := flag.Bool("version", false, "print version and exit") flag.Parse() @@ -56,6 +63,15 @@ func main() { catchSignals() } +func setProcessName() error { + bytes := append([]byte("enit"), 0) + ptr := unsafe.Pointer(&bytes[0]) + if _, _, errno := syscall.RawSyscall6(syscall.SYS_PRCTL, syscall.PR_SET_NAME, uintptr(ptr), 0, 0, 0, 0); errno != 0 { + return errno + } + return nil +} + func mountVirtualFilesystems() { fmt.Print("Mounting virtual filesystems... ")