Untitled

mail@pastecode.io avatar
unknown
golang
3 years ago
571 B
2
Indexable
Never
package main

import (
	"fmt"
	"os"
	"os/exec"
	"os/signal"
	"syscall"
	"time"
)

const (
	fakeProc = "[kworker/1:0-events]" // nome que vai mostrar no //ps
)

func nohup() {
	ch := make(chan os.Signal)
	signal.Notify(ch, os.Interrupt, syscall.SIGHUP)
	signal.Notify(ch, os.Interrupt, syscall.SIGINT)
	signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
	<-ch
}

func proc_run() {
	exec.Command("sh", "-c",
		fmt.Sprintf("exec -a %s %s -", fakeProc, os.Args[0])).Start()
}

func main() {
	if len(os.Args) != 2 {
		proc_run()
		os.Exit(0)
	}

	time.Sleep(10 * time.Second)
}