The Windows app cross-compiles (WebView2, no cgo) as a GUI program with an icon, version info and a DPI-aware manifest; run from a terminal with a command it borrows the console. The Linux app links GTK 3 and WebKitGTK 4.1. Off the Mac the app updates its own binary from its own build: downloaded in the background, swapped in on restart or quit, and the relaunched process waits for the old one before taking the gateway. The window leaves room for traffic lights only on a Mac.
24 lines
538 B
Go
24 lines
538 B
Go
//go:build !windows
|
|
|
|
package update
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// alive reports whether pid is still running. A relaunched magpie is that
|
|
// process's child, so its exit shows as a new parent even before the
|
|
// process table lets go of it.
|
|
func alive(pid int) bool {
|
|
if os.Getppid() != pid {
|
|
return syscall.Kill(pid, 0) == nil
|
|
}
|
|
return true
|
|
}
|
|
|
|
// detach keeps a relaunched magpie out of this one's process group, so it
|
|
// outlives it.
|
|
func detach(cmd *exec.Cmd) { cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} }
|