aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/hpkg/with.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-29 02:33:10 +0900
committerOphestra <cat@gensokyo.uk>2025-09-29 06:11:47 +0900
commit46cd3a28c83e93b5d66c52d06a8366c11910d5c0 (patch)
tree6e25c5078b5cd9de78b7a6c9b253f1132358812b /cmd/hpkg/with.go
parentad1bc6794f0053c3e63eab408a0d530d53e8b51c (diff)
container: remove global msg
This frees all container instances of side effects. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/hpkg/with.go')
-rw-r--r--cmd/hpkg/with.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/cmd/hpkg/with.go b/cmd/hpkg/with.go
index 1895a06f..578d5251 100644
--- a/cmd/hpkg/with.go
+++ b/cmd/hpkg/with.go
@@ -2,20 +2,21 @@ package main
import (
"context"
+ "os"
"strings"
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/hst"
- "hakurei.app/internal"
)
func withNixDaemon(
ctx context.Context,
+ msg container.Msg,
action string, command []string, net bool, updateConfig func(config *hst.Config) *hst.Config,
app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func(),
) {
- mustRunAppDropShell(ctx, updateConfig(&hst.Config{
+ mustRunAppDropShell(ctx, msg, updateConfig(&hst.Config{
ID: app.ID,
Path: pathShell,
@@ -61,9 +62,10 @@ func withNixDaemon(
func withCacheDir(
ctx context.Context,
+ msg container.Msg,
action string, command []string, workDir *container.Absolute,
app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func()) {
- mustRunAppDropShell(ctx, &hst.Config{
+ mustRunAppDropShell(ctx, msg, &hst.Config{
ID: app.ID,
Path: pathShell,
@@ -97,12 +99,13 @@ func withCacheDir(
}, dropShell, beforeFail)
}
-func mustRunAppDropShell(ctx context.Context, config *hst.Config, dropShell bool, beforeFail func()) {
+func mustRunAppDropShell(ctx context.Context, msg container.Msg, config *hst.Config, dropShell bool, beforeFail func()) {
if dropShell {
config.Args = []string{bash, "-l"}
- mustRunApp(ctx, config, beforeFail)
+ mustRunApp(ctx, msg, config, beforeFail)
beforeFail()
- internal.Exit(0)
+ msg.BeforeExit()
+ os.Exit(0)
}
- mustRunApp(ctx, config, beforeFail)
+ mustRunApp(ctx, msg, config, beforeFail)
}