Fix error handling in goroutine

This commit is contained in:
Carter Dodd
2022-05-13 23:03:04 -05:00
parent a27be52e3f
commit 42cc91162d

View File

@@ -28,6 +28,8 @@ func FirstError(errs ...error) (err error) {
wwlog.ErrorExc(e, "Unhandled error")
}
}
return
}
func DirModTime(path string) (time.Time, error) {
@@ -530,10 +532,11 @@ func CpioCreate(
return err
}
var err_in error
err_in := make(chan error, 1)
go func() {
defer stdin.Close()
_, err_in := io.WriteString(stdin, strings.Join(ifiles, "\n"))
_, err := io.WriteString(stdin, strings.Join(ifiles, "\n"))
err_in <- err
}()
out, err := proc.CombinedOutput()
@@ -541,7 +544,7 @@ func CpioCreate(
wwlog.Debug(string(out))
}
return FirstError(err, err_in)
return FirstError(err, <- err_in)
}
/*******************************************************************************