File tree Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ go 1.22.4
5
5
require (
6
6
github.com/evalphobia/logrus_sentry v0.8.2
7
7
github.com/prometheus/client_golang v1.19.1
8
+ github.com/ramr/go-reaper v0.2.1
8
9
github.com/sirupsen/logrus v1.9.3
9
10
github.com/stretchr/testify v1.8.0
10
11
)
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSz
30
30
github.com/prometheus/common v0.48.0 /go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc =
31
31
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo =
32
32
github.com/prometheus/procfs v0.12.0 /go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo =
33
+ github.com/ramr/go-reaper v0.2.1 h1:zww+wlQOvTjBZuk1920R/e0GFEb6O7+B0WQLV6dM924 =
34
+ github.com/ramr/go-reaper v0.2.1 /go.mod h1:AVypdzrcCXjSc/JYnlXl8TsB+z84WyFzxWE8Jh0MOJc =
33
35
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M =
34
36
github.com/rogpeppe/go-internal v1.11.0 /go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA =
35
37
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ =
Original file line number Diff line number Diff line change @@ -101,3 +101,15 @@ wait_for() {
101
101
@test " it errors on an invalid crontab" {
102
102
! run_supercronic -test " ${BATS_TEST_DIRNAME} /invalid.crontab"
103
103
}
104
+
105
+ @test " reap zombie process" {
106
+ # run in new process namespace
107
+ sudo timeout 10s unshare --fork --pid --mount-proc \
108
+ ${BATS_TEST_DIRNAME} /../supercronic " ${BATS_TEST_DIRNAME} /zombie.crontab" &
109
+ local pid=$!
110
+ sleep 1.5
111
+ run bash -c " ps axo pid=,stat=|grep Z"
112
+ kill -TERM ${pid}
113
+
114
+ [[ " $status " -eq 1 ]]
115
+ }
Original file line number Diff line number Diff line change
1
+ * * * * * * * /bin/sleep 1 & exec /bin/sleep 0
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
15
15
"github.com/aptible/supercronic/log/hook"
16
16
"github.com/aptible/supercronic/prometheus_metrics"
17
17
"github.com/evalphobia/logrus_sentry"
18
+ reaper "github.com/ramr/go-reaper"
18
19
"github.com/sirupsen/logrus"
19
20
)
20
21
@@ -144,6 +145,10 @@ func main() {
144
145
}()
145
146
}
146
147
148
+ // Start background reaping of orphaned child processes.
149
+ go reaper .Reap ()
150
+ // _ = reaper.Reap
151
+
147
152
for {
148
153
promMetrics .Reset ()
149
154
You can’t perform that action at this time.
0 commit comments