def alive

cswap-bend-cli@0.1.0.0 · tui/run.bend:129

import cswap-bend-cli@0.1.0.0/tui/run.bend as Run
import Base

129# Is the daemon's pid alive? `kill -0` answers without signalling.
130def alive(+pid: Maybe<&2, U32>) -> IO(Bool):
131  match pid:
132    case None{}:
133      IO.pure(Bool, False{})
134    case Some{p}:
135      IO.bind(Result<&1, &1, U32 & String, U32 & (String & String)>, Bool, Process.run("kill", ["-0", U32.show(p)], "", 64, 2000), r => IO.pure(Bool, U32.is_eq(code_pick(r), 0)))

Uses (14)

Used by (1)