diff --git a/iodaemon/iodaemon.go b/iodaemon/iodaemon.go index 517eecdc..49502e6c 100644 --- a/iodaemon/iodaemon.go +++ b/iodaemon/iodaemon.go @@ -36,8 +36,10 @@ func Spawn( return err } + currentPid := os.Getpid() pid := strings.Split(filepath.Base(socketPath), ".")[0] - logFile, err = os.OpenFile(filepath.Join(filepath.Dir(socketPath), fmt.Sprintf(pid+".iodaemon")), os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) + logFilePath := filepath.Join(filepath.Dir(socketPath), fmt.Sprintf("%s.%d.iodaemon", pid, currentPid)) + logFile, err = os.OpenFile(logFilePath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) if err != nil { panic(err) } @@ -105,6 +107,8 @@ func Spawn( exit = byte(ws.ExitStatus()) } + logFile.Close() + os.Remove(logFilePath) fmt.Fprintf(statusW, "%d\n", exit) case <-time.After(timeout): contents, err := ioutil.ReadFile("/proc/net/unix") @@ -115,7 +119,7 @@ func Spawn( } fmt.Fprintf(logFile, "output of netstat -xap: \n") - cmd := exec.Command("netstat", "-xap") + cmd := exec.Command("/bin/netstat", "-xap") cmd.Stdout = logFile cmd.Stderr = logFile if err := cmd.Run(); err != nil { diff --git a/process_tracker/process.go b/process_tracker/process.go index a922bf2c..eae182c5 100644 --- a/process_tracker/process.go +++ b/process_tracker/process.go @@ -179,20 +179,6 @@ func (p *Process) Spawn(cmd *exec.Cmd, tty *garden.TTYSpec) (ready, active chan } go func() { - _, err := spawnOut.ReadBytes('\n') - if err != nil { - stderrContents, readErr := ioutil.ReadAll(spawnErr) - if readErr != nil { - ready <- fmt.Errorf("failed to read ready (%s), and failed to read the stderr: %s", err, readErr) - return - } - - ready <- fmt.Errorf("failed to read ready (%s): %s", err, string(stderrContents)) - return - } - - ready <- nil - waitFor := func(expectedLog string) error { p.logger.Info("waiting for " + expectedLog) log, err := spawnOut.ReadBytes('\n') @@ -221,6 +207,12 @@ func (p *Process) Spawn(cmd *exec.Cmd, tty *garden.TTYSpec) (ready, active chan return nil } + if waitFor("ready") != nil { + return + } + + ready <- nil + if waitFor("listener-accepted") != nil { return } @@ -247,6 +239,8 @@ func (p *Process) Spawn(cmd *exec.Cmd, tty *garden.TTYSpec) (ready, active chan active <- nil spawn.Wait() + + os.Remove(straceOutput) }() return