1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-10 22:39:37 -04:00

refactor(sysupdate): Streamline DMS Updater command handling

This commit is contained in:
purian23
2026-05-05 15:16:36 -04:00
parent b209827f38
commit d49c49cd99
13 changed files with 405 additions and 99 deletions

View File

@@ -14,8 +14,9 @@ import (
)
type RunOptions struct {
Env []string
OnLine func(string)
Env []string
OnLine func(string)
AttachStdio bool
}
func Run(ctx context.Context, argv []string, opts RunOptions) error {
@@ -27,6 +28,19 @@ func Run(ctx context.Context, argv []string, opts RunOptions) error {
if len(opts.Env) > 0 {
cmd.Env = append(cmd.Environ(), opts.Env...)
}
if opts.AttachStdio {
cmd.Cancel = func() error {
if cmd.Process == nil {
return nil
}
return cmd.Process.Kill()
}
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Cancel = func() error {
if cmd.Process == nil {