diff --git a/internal/proc/rss_test.go b/internal/proc/rss_test.go index 2d2198065..f6f197587 100644 --- a/internal/proc/rss_test.go +++ b/internal/proc/rss_test.go @@ -4,6 +4,7 @@ import ( "os/exec" "runtime" "testing" + "time" ) // A running tree's resident memory is read, and none once it was waited @@ -20,7 +21,13 @@ func TestTreeRSS(t *testing.T) { if err != nil { t.Fatal(err) } + // just after its exec a command holds a few pages, until its loader + // maps what it runs on (16KiB on ubuntu CI), so it is read until it does rss, ok := tree.RSS() + for end := time.Now().Add(10 * time.Second); ok && rss < 64<<10 && time.Now().Before(end); { + time.Sleep(20 * time.Millisecond) + rss, ok = tree.RSS() + } if !ok || rss < 64<<10 || rss > 1<<30 { t.Fatalf("a running %s holds %d bytes (%v)", name, rss, ok) } diff --git a/internal/tui/keep.go b/internal/tui/keep.go index ae35c97e2..079309d49 100644 --- a/internal/tui/keep.go +++ b/internal/tui/keep.go @@ -3,7 +3,6 @@ package tui import ( "fmt" "os" - "os/exec" "path/filepath" "runtime" "strings" @@ -12,6 +11,7 @@ import ( "github.com/yetone/magpie/internal/appdir" "github.com/yetone/magpie/internal/autostart" "github.com/yetone/magpie/internal/daemon" + "github.com/yetone/magpie/internal/proc" ) // On Linux with no desktop session (a WSL distro, a server over SSH) @@ -99,7 +99,7 @@ func serveInBackground() (int, string, error) { return 0, "", err } defer f.Close() - cmd := exec.Command(exe, "serve") + cmd := proc.Command(exe, "serve") cmd.Stdout, cmd.Stderr = f, f detach(cmd) if err := cmd.Start(); err != nil {