mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
Set environment variable LABWC_PID
...to the pid of the compositor so that SIGHUP and SIGTERM can be sent to specific instances using `kill -s <signal> <pid>` rather than `killall -s <signal> labwc` Issue #573
This commit is contained in:
parent
3d8f528266
commit
2c06b902f4
1 changed files with 14 additions and 0 deletions
14
src/main.c
14
src/main.c
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "common/dir.h"
|
#include "common/dir.h"
|
||||||
#include "common/fd_util.h"
|
#include "common/fd_util.h"
|
||||||
#include "common/font.h"
|
#include "common/font.h"
|
||||||
|
|
@ -81,6 +82,19 @@ main(int argc, char *argv[])
|
||||||
session_environment_init(rc.config_dir);
|
session_environment_init(rc.config_dir);
|
||||||
rcxml_read(config_file);
|
rcxml_read(config_file);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set environment variable LABWC_PID to the pid of the compositor
|
||||||
|
* so that SIGHUP and SIGTERM can be sent to specific instances using
|
||||||
|
* `kill -s <signal> <pid>` rather than `killall -s <signal> labwc`
|
||||||
|
*/
|
||||||
|
char pid[32];
|
||||||
|
snprintf(pid, sizeof(pid), "%d", getpid());
|
||||||
|
if (setenv("LABWC_PID", pid, true) < 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "unable to set LABWC_PID");
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_DEBUG, "LABWC_PID=%s", pid);
|
||||||
|
}
|
||||||
|
|
||||||
if (!getenv("XDG_RUNTIME_DIR")) {
|
if (!getenv("XDG_RUNTIME_DIR")) {
|
||||||
wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is unset");
|
wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is unset");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue