ladybird/Libraries/LibWebView/ProcessMonitor.h
ayeteadoe 433ff624b8 LibWebView: Abstract process exit monitoring into ProcessMonitor
There is no direct equivalent to SIGCHILD on Windows. The closest we
can get is monitoring a specific process, given a known pid. On Unix
there is no single solution to be able to do that in LibCore's
EventLoopImplementationUnix. For Linux there's a SYS_pidfd_open syscall
that can integrate into poll(), but on macOS a kqueue would be needed.
Given macOS uses EventLoopImplementationUnix for the headless view
implementation, we currently can't create a fully cross-platform
abstaction at the Event Loop level to match what Windows needs to do.

ProcessMonitor's purpose is to abstract away the Unix vs Windows
behaviour avoiding more inlined ifdef soup in ProcessManager.
2026-04-12 16:08:07 +02:00

27 lines
492 B
C++

/*
* Copyright (c) 2025, ayeteadoe <ayeteadoe@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <AK/HashTable.h>
namespace WebView {
class ProcessMonitor {
public:
ProcessMonitor(Function<void(pid_t)> exit_handler);
~ProcessMonitor();
void add_process(pid_t pid);
private:
Function<void(pid_t)> m_on_process_exit;
HashTable<pid_t> m_monitored_processes;
[[maybe_unused]] int m_signal_handle { -1 };
};
}