aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/outcome/shim.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-30 00:46:23 +0900
committerOphestra <cat@gensokyo.uk>2025-10-30 01:20:51 +0900
commiteeb9f98e5bd9d4fac6706edb87d06bf757f0fb79 (patch)
tree5417d1c2e18d87be6d5d6a90db7d6f8a4546ba5d /internal/outcome/shim.go
parent3f9f331501acc3dc367276501822ef1a260dfd24 (diff)
internal/outcome/shim: move signal constants
The magic numbers hurt readability. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/outcome/shim.go')
-rw-r--r--internal/outcome/shim.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/internal/outcome/shim.go b/internal/outcome/shim.go
index a16bdc70..acc962c1 100644
--- a/internal/outcome/shim.go
+++ b/internal/outcome/shim.go
@@ -22,6 +22,17 @@ import (
//#include "shim-signal.h"
import "C"
+const (
+ /* hakurei requests shim exit */
+ shimMsgExitRequested = C.HAKUREI_SHIM_EXIT_REQUESTED
+ /* shim orphaned before hakurei delivers a signal */
+ shimMsgOrphaned = C.HAKUREI_SHIM_ORPHAN
+ /* unreachable */
+ shimMsgInvalid = C.HAKUREI_SHIM_INVALID
+ /* unexpected si_pid */
+ shimMsgBadPID = C.HAKUREI_SHIM_BAD_PID
+)
+
// setupContSignal sets up the SIGCONT signal handler for the cross-uid shim exit hack.
// The signal handler is implemented in C, signals can be processed by reading from the returned reader.
// The returned function must be called after all signal processing concludes.
@@ -161,7 +172,7 @@ func shimEntrypoint(k syscallDispatcher) {
}
switch buf[0] {
- case 0: // got SIGCONT from monitor: shim exit requested
+ case shimMsgExitRequested: // got SIGCONT from hakurei: shim exit requested
if fp := cancelContainer.Load(); stateParams.params.ForwardCancel && fp != nil && *fp != nil {
(*fp)()
// shim now bound by ShimWaitDelay, implemented below
@@ -171,13 +182,13 @@ func shimEntrypoint(k syscallDispatcher) {
// setup has not completed, terminate immediately
k.exit(hst.ExitRequest)
- case 1: // got SIGCONT via pdeath_signal: monitor died before delivering signal
+ case shimMsgOrphaned: // got SIGCONT after orphaned: hakurei died before delivering signal
k.exit(hst.ExitOrphan)
- case 2: // unreachable
+ case shimMsgInvalid: // unreachable
msg.Verbose("sa_sigaction got invalid siginfo")
- case 3: // got SIGCONT from unexpected process: hopefully the terminal driver
+ case shimMsgBadPID: // got SIGCONT from unexpected process: hopefully the terminal driver
msg.Verbose("got SIGCONT from unexpected process")
default: // unreachable