aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fpkg
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-04-05 23:51:39 +0900
committerOphestra <cat@gensokyo.uk>2025-04-07 03:55:17 +0900
commite9a7cd526f4e5f0a8f7b18ad3682d2e3afbcb8ba (patch)
tree5b5ac59efa97d2d57d38c094dada9aff22bee72c /cmd/fpkg
parent12be7bc78e093ef609c9b2a491239cc59721fec6 (diff)
app: improve shim process management
This ensures a signal gets delivered to the process instead of relying on parent death behaviour. SIGCONT was chosen as it is the only signal an unprivileged process is allowed to send to processes with different credentials. A custom signal handler is installed because the Go runtime does not expose signal information other than which signal was received, and shim must check pid to ensure reasonable behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/fpkg')
-rw-r--r--cmd/fpkg/proc.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/cmd/fpkg/proc.go b/cmd/fpkg/proc.go
index 311ae4f2..677ddb75 100644
--- a/cmd/fpkg/proc.go
+++ b/cmd/fpkg/proc.go
@@ -13,16 +13,16 @@ func mustRunApp(ctx context.Context, config *fst.Config, beforeFail func()) {
rs := new(fst.RunState)
a := app.MustNew(ctx, std)
+ var code int
if sa, err := a.Seal(config); err != nil {
fmsg.PrintBaseError(err, "cannot seal app:")
- rs.ExitCode = 1
+ code = 1
} else {
- // this updates ExitCode
- app.PrintRunStateErr(rs, sa.Run(rs))
+ code = app.PrintRunStateErr(rs, sa.Run(rs))
}
- if rs.ExitCode != 0 {
+ if code != 0 {
beforeFail()
- os.Exit(rs.ExitCode)
+ os.Exit(code)
}
}