diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-12 23:12:38 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-12 23:16:13 +0900 |
| commit | f347d44c2281f507e3786aa498f634bfa4c92d84 (patch) | |
| tree | fe85b41d5f6a5e308b87585f46efd64f90221e2b /helper/helper.go | |
| parent | b5630f6883c874d458d9ae3c666cfb7ae5e3121d (diff) | |
internal/helper: relocate from helper
This package is ugly and is pending removal only kept alive by xdg-dbus-proxy.
Its exported symbols are made available until v0.4.0 where it will be removed for #24.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/helper.go')
| -rw-r--r-- | helper/helper.go | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/helper/helper.go b/helper/helper.go deleted file mode 100644 index 60bd7615..00000000 --- a/helper/helper.go +++ /dev/null @@ -1,83 +0,0 @@ -// Package helper runs external helpers with optional sandboxing. -package helper - -import ( - "context" - "fmt" - "io" - "os" - "time" - - "hakurei.app/helper/proc" -) - -var WaitDelay = 2 * time.Second - -const ( - // HakureiHelper is set to 1 when args fd is enabled and 0 otherwise. - HakureiHelper = "HAKUREI_HELPER" - // HakureiStatus is set to 1 when stat fd is enabled and 0 otherwise. - HakureiStatus = "HAKUREI_STATUS" -) - -type Helper interface { - // Start starts the helper process. - Start() error - // Wait blocks until Helper exits. - Wait() error - - fmt.Stringer -} - -func newHelperFiles( - ctx context.Context, - wt io.WriterTo, - stat bool, - argF func(argsFd, statFd int) []string, - extraFiles []*os.File, -) (hl *helperFiles, args []string) { - hl = new(helperFiles) - hl.ctx = ctx - hl.useArgsFd = wt != nil - hl.useStatFd = stat - - hl.extraFiles = new(proc.ExtraFilesPre) - for _, f := range extraFiles { - _, v := hl.extraFiles.Append() - *v = f - } - - argsFd := -1 - if hl.useArgsFd { - f := proc.NewWriterTo(wt) - argsFd = int(proc.InitFile(f, hl.extraFiles)) - hl.files = append(hl.files, f) - } - - statFd := -1 - if hl.useStatFd { - f := proc.NewStat(&hl.stat) - statFd = int(proc.InitFile(f, hl.extraFiles)) - hl.files = append(hl.files, f) - } - - args = argF(argsFd, statFd) - return -} - -// helperFiles provides a generic wrapper around helper ipc. -type helperFiles struct { - // whether argsFd is present - useArgsFd bool - // whether statFd is present - useStatFd bool - - // closes statFd - stat io.Closer - // deferred extraFiles fulfillment - files []proc.File - // passed through to [proc.Fulfill] and [proc.InitFile] - extraFiles *proc.ExtraFilesPre - - ctx context.Context -} |
