From aef06629e6791498db6a9f14f85dc1594ddc9a27 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 27 Feb 2025 18:09:32 +0100 Subject: [PATCH] ev::wait: remove error case It's a programmer error, so assert. Signed-off-by: Drew DeVault --- cmd/child/main.ha | 2 +- ev/+linux/process.ha | 9 +++------ diff --git a/cmd/child/main.ha b/cmd/child/main.ha index 9808ba82871f7a43fb6a0c6af88ddf4579db6c25..7a999e60e21f9f9deeb5dff122d693e7e3a06d24 100644 --- a/cmd/child/main.ha +++ b/cmd/child/main.ha @@ -11,7 +11,7 @@ defer ev::finish(&loop); const cmd = exec::cmd(os::args[1], os::args[2..]...)!; const child = ev::exec(&loop, &cmd)!; - ev::wait(child, &child_exited)!; + ev::wait(child, &child_exited); const timer = ev::newtimer(&loop, &expired, time::clock::MONOTONIC)!; ev::timer_configure(timer, 5 * time::SECOND, 0); diff --git a/ev/+linux/process.ha b/ev/+linux/process.ha index 2c325b9a8931372a4e54f5c2b272bea12033e800..18f23ba91bd980b74d1e50f348a077dc94fb1607 100644 --- a/ev/+linux/process.ha +++ b/ev/+linux/process.ha @@ -37,17 +37,14 @@ export type waitcb = fn(file: *file, result: exec::status) void; // Waits for a process to exit. After the callback is run, the [[file]] is // closed and unregistered from the event loop and may not be used again. -export fn wait(proc: *file, cb: *waitcb) (req | errors::error) = { +export fn wait(proc: *file, cb: *waitcb) req = { assert(proc.op & op::WAIT == 0); // Attempt to waitid now to hit error cases early match (do_waitid(proc, cb, rt::WNOHANG)) { case let err: rt::errno => - // We expect EAGAIN, anything else indicates that something went - // wrong (e.g. EBADF if using a non-pidfd with ev::wait) - if (err != rt::EAGAIN) { - return errors::errno(err); - }; + assert(err == rt::EAGAIN, + "ev::wait: unexpected error from waitid (not a pidfd?)"); case void => // Child has already exited. do_waitid ran the callback, so we // can return with no further fanfare -- 2.48.1