![]() |
Louvre
v2.9.0-1
C++ library for Wayland compositors
|
Utility for launching applications safely. More...
Static Public Member Functions | |
static pid_t | startDaemon (const std::string &name="LLauncher") |
Starts the daemon and returns its process ID. More... | |
static pid_t | pid () |
Gets the process ID (PID) of the daemon. More... | |
static pid_t | launch (const std::string &command) |
Launches an application. More... | |
static void | stopDaemon () |
Terminates the daemon. More... | |
Utility for launching applications safely.
Creating a fork of the compositor while it's running is a risky operation that can result in resource leaks to child processes, leading to undesired behaviors and potentially causing the compositor to experience reduced performance or crashes.
The LLauncher class is an auxiliary class designed to facilitate the secure launching of applications from the compositor. It creates a background daemon capable of launching applications using the system() call.
The daemon must be started before creating an instance of LCompositor, achieved through the startDaemon() function. The daemon can be terminated by calling the stopDaemon() function and is automatically exited when the compositor ends.
If the daemon exits normally, it sends a SIGTERM signal to all processes in its process group.
|
static |
Starts the daemon and returns its process ID.
Should preferably be the first function called from the main()
function and must be called before creating an instance of LCompositor.
name | The process name to be set for the daemon. |
|
static |
Gets the process ID (PID) of the daemon.
|
static |
Launches an application.
This function uses the same arguments as the system() call. It launches an application specified by the provided command and returns the application's process ID.
command | The command to execute, as a string. |
|
static |
Terminates the daemon.
Calling this method when the daemon is not running is a no-op.