shim: user switcher process management struct

This change moves all user switcher and shim management to the shim package and withholds output while shim is alive. This also eliminated all exit scenarios where revert is skipped.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
2024-10-27 00:46:15 +09:00
parent ae1a102882
commit 1d6ea81205
7 changed files with 332 additions and 182 deletions

13
main.go
View File

@@ -53,15 +53,18 @@ func main() {
tryState()
// invoke app
r := 1
a, err := app.New(os)
if err != nil {
fmsg.Fatalf("cannot create app: %s\n", err)
} else if err = a.Seal(loadConfig()); err != nil {
logBaseError(err, "fortify: cannot seal app:")
logBaseError(err, "cannot seal app:")
} else if err = a.Start(); err != nil {
logBaseError(err, "fortify: cannot start app:")
} else if r, err = a.Wait(); err != nil {
logBaseError(err, "cannot start app:")
}
var r int
// wait must be called regardless of result of start
if r, err = a.Wait(); err != nil {
if r < 1 {
r = 1
}
@@ -70,5 +73,5 @@ func main() {
if err = a.WaitErr(); err != nil {
fmsg.Println("inner wait failed:", err)
}
os.Exit(r)
fmsg.Exit(r)
}