
---@class spawn_wait*
---@type spawn_wait*
local M = {}

---@class spawn_wait_options*
---@field nohang? boolean No blocking wait.
---@field untraced? boolean Returns the stopped child process status.
---@field continued? boolean Return to continue running the child process state.

--- Wait for the process to end.
---@param pid integer process number.
---@param options? integer|spawn_wait_options* waitpid options。
---@return boolean? ok True when exiting successfully; false when nohang and no state changes; nil when exception or error occurs.
---@return "exit"|"signal"|"stop"|string? reason Ending reason or error message.
---@return integer? status Status code or errno.
function M.waitpid(pid, options) end

return M
