aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fpkg/proc.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-16 17:26:09 +0900
committerOphestra <cat@gensokyo.uk>2025-02-16 18:51:53 +0900
commite599b5583dd821ed26bdfc01f7f67d4a317b9843 (patch)
treeb444a3dc964814360e6779bc10b30f2e599b537c /cmd/fpkg/proc.go
parent33a4ab11c226c736c0d8b2644fbbe27a5ca045e9 (diff)
fmsg: implement suspend in writer
This removes the requirement to call fmsg.Exit on every exit path, and enables direct use of the "log" package. However, fmsg.BeforeExit is still encouraged when possible to catch exit on suspended output. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/fpkg/proc.go')
-rw-r--r--cmd/fpkg/proc.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/cmd/fpkg/proc.go b/cmd/fpkg/proc.go
index 7fa6df5a..4413496a 100644
--- a/cmd/fpkg/proc.go
+++ b/cmd/fpkg/proc.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"io"
+ "log"
"os"
"os/exec"
@@ -25,14 +26,12 @@ func fortifyApp(config *fst.Config, beforeFail func()) {
)
if p, ok := internal.Path(Fmain); !ok {
beforeFail()
- fmsg.Fatal("invalid fortify path, this copy of fpkg is not compiled correctly")
- panic("unreachable")
+ log.Fatal("invalid fortify path, this copy of fpkg is not compiled correctly")
} else if r, w, err := os.Pipe(); err != nil {
beforeFail()
- fmsg.Fatalf("cannot pipe: %v", err)
- panic("unreachable")
+ log.Fatalf("cannot pipe: %v", err)
} else {
- if fmsg.Verbose() {
+ if fmsg.Load() {
cmd = exec.Command(p, "-v", "app", "3")
} else {
cmd = exec.Command(p, "app", "3")
@@ -45,26 +44,22 @@ func fortifyApp(config *fst.Config, beforeFail func()) {
go func() {
if err := json.NewEncoder(st).Encode(config); err != nil {
beforeFail()
- fmsg.Fatalf("cannot send configuration: %v", err)
- panic("unreachable")
+ log.Fatalf("cannot send configuration: %v", err)
}
}()
if err := cmd.Start(); err != nil {
beforeFail()
- fmsg.Fatalf("cannot start fortify: %v", err)
- panic("unreachable")
+ log.Fatalf("cannot start fortify: %v", err)
}
if err := cmd.Wait(); err != nil {
var exitError *exec.ExitError
if errors.As(err, &exitError) {
beforeFail()
- fmsg.Exit(exitError.ExitCode())
- panic("unreachable")
+ internal.Exit(exitError.ExitCode())
} else {
beforeFail()
- fmsg.Fatalf("cannot wait: %v", err)
- panic("unreachable")
+ log.Fatalf("cannot wait: %v", err)
}
}
}