Exemple #1
0
func RunExternalDump(cmd, wd string, argv []string, dump io.Writer) (err os.Error) {
	var p *exec.Cmd
	p, err = exec.Run(cmd, argv, nil, wd, exec.PassThrough, exec.Pipe, exec.PassThrough)
	if err != nil {
		return
	}
	if p != nil {
		src := p.Stdout
		buffer := make([]byte, 1024)
		for {
			n, cpErr := src.Read(buffer)
			if cpErr != nil {
				break
			}
			_, cpErr = dump.Write(buffer[0:n])
			if cpErr != nil {
				break
			}
		}

		var wmsg *os.Waitmsg
		wmsg, err = p.Wait(0)
		if wmsg.ExitStatus() != 0 {
			err = os.NewError(fmt.Sprintf("%v: %s\n", argv, wmsg.String()))
			return
		}
		if err != nil {
			return
		}
	}
	return
}
Exemple #2
0
func (sv *service) exited(w *os.Waitmsg) {
	if w.Pid != sv.pid {
		return
	}
	sv.pid = 0

	sv.logger.Println(w)
	go sv.delStatus("pid")

	if sv.isFatal(w) {
		sv.wantUp = false
		sv.logger.Println("fatal error")
	}
	go sv.setStatus("status", "down")
	go sv.setStatus("reason", w.String())

	if sv.so != nil {
		sv.so.exited()
	}

	sv.check()
}
Exemple #3
0
func exitedCleanly(w *os.Waitmsg) bool {
	return w.Exited() && w.ExitStatus() == 0
}