aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/pkg.go39
1 files changed, 31 insertions, 8 deletions
diff --git a/pkg/pkg.go b/pkg/pkg.go
index 2d102666..49f6f5a1 100644
--- a/pkg/pkg.go
+++ b/pkg/pkg.go
@@ -24,6 +24,7 @@ import (
"maps"
"math"
"os"
+ "os/exec"
"path/filepath"
"runtime"
"slices"
@@ -224,6 +225,24 @@ func (t *TContext) GetStatusWriter() (io.Writer, error) {
return t.status, err
}
+// isReportable returns whether an error should be recorded. A typical example
+// of a non-reportable error is [Collected].
+func isReportable(err error) bool {
+ if IsCollected(err) {
+ return false
+ }
+
+ var wstatus syscall.WaitStatus
+ if e, ok := errors.AsType[*exec.ExitError](err); ok {
+ if wstatus, ok = e.Sys().(syscall.WaitStatus); ok &&
+ wstatus.Signaled() && wstatus.Signal() == syscall.SIGKILL {
+ return false
+ }
+ }
+
+ return true
+}
+
// destroy destroys the temporary directory and joins its errors with the error
// referred to by errP. If the error referred to by errP is non-nil, the work
// directory is removed similarly. [Cache] is responsible for making sure work
@@ -259,14 +278,18 @@ func (t *TContext) destroy(errP *error) {
*errP = errors.Join(*errP, err)
}
if *errP != nil {
- *errP = errors.Join(*errP, os.Rename(
- t.statusPath.String(), t.cache.base.Append(
- dirFault,
- t.ids+"."+strconv.FormatUint(uint64(
- time.Now().UnixNano(),
- ), 10),
- ).String(),
- ))
+ if isReportable(*errP) {
+ *errP = errors.Join(*errP, os.Rename(
+ t.statusPath.String(), t.cache.base.Append(
+ dirFault,
+ t.ids+"."+strconv.FormatUint(uint64(
+ time.Now().UnixNano(),
+ ), 10),
+ ).String(),
+ ))
+ } else {
+ *errP = errors.Join(*errP, os.Remove(t.statusPath.String()))
+ }
if t.statusSPath != nil {
t.cache.checksumMu.Lock()
*errP = errors.Join(*errP, os.Remove(t.statusSPath.String()))