aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/app/app.go')
-rw-r--r--internal/app/app.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
new file mode 100644
index 00000000..9d1165f4
--- /dev/null
+++ b/internal/app/app.go
@@ -0,0 +1,52 @@
+package app
+
+import (
+ "os/exec"
+ "sync"
+)
+
+type App interface {
+ Seal(config *Config) error
+ Start() error
+ Wait() (int, error)
+ WaitErr() error
+ String() string
+}
+
+type app struct {
+ // child process related information
+ seal *appSeal
+ // underlying fortified child process
+ cmd *exec.Cmd
+ // error returned waiting for process
+ wait error
+
+ lock sync.RWMutex
+}
+
+func (a *app) String() string {
+ if a == nil {
+ return "(invalid fortified app)"
+ }
+
+ a.lock.RLock()
+ defer a.lock.RUnlock()
+
+ if a.cmd != nil {
+ return a.cmd.String()
+ }
+
+ if a.seal != nil {
+ return "(sealed fortified app as uid " + a.seal.sys.Uid + ")"
+ }
+
+ return "(unsealed fortified app)"
+}
+
+func (a *app) WaitErr() error {
+ return a.wait
+}
+
+func New() App {
+ return new(app)
+}