X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=main.go;h=c3b1be78677b731291db45ca8af4cfab7b74a5d3;hb=7648b1c670d38b62b6328824ceecd50303945fdf;hp=4338d0031cf606c22b87ec9616519c8fc6120aba;hpb=9c7d2ee7e4847ba9194f2e96ec460b8c024e551f;p=goredo.git diff --git a/main.go b/main.go index 4338d00..c3b1be7 100644 --- a/main.go +++ b/main.go @@ -27,11 +27,13 @@ import ( "io/ioutil" "log" "os" + "os/signal" "path" "path/filepath" "runtime" "sort" "strconv" + "syscall" "go.cypherpunks.ru/recfile" "golang.org/x/sys/unix" @@ -282,6 +284,20 @@ func main() { } } + killed := make(chan os.Signal, 0) + signal.Notify(killed, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM) + go func() { + <-killed + trace(CDebug, "[%s] killed", BuildUUID) + jsReleaseAll() + RunningProcsM.Lock() + for pid, proc := range RunningProcs { + trace(CDebug, "[%s] killing child %d", BuildUUID, pid) + proc.Signal(syscall.SIGTERM) + } + os.Exit(1) + }() + ok := true err = nil trace( @@ -308,7 +324,14 @@ CmdSwitch: log.Fatalln("no", EnvDepFd) } for _, tgt := range tgts { - err = ifcreate(fdDep, tgt) + tgtRel, err := filepath.Rel( + filepath.Join(Cwd, DirPrefix), + filepath.Join(Cwd, tgt), + ) + if err != nil { + break + } + err = ifcreate(fdDep, tgtRel) if err != nil { break }