create an environment pointer for child processes

This commit is contained in:
slonkazoid 2024-09-08 18:22:00 +03:00
parent 8830b1f992
commit f7d611af7b
No known key found for this signature in database

View file

@ -1,5 +1,6 @@
#include <getopt.h>
#include <pango/pangocairo.h>
#include <glib.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
@ -30,6 +31,7 @@ static int exit_value = 0;
static struct rlimit original_nofile_rlimit = {0};
struct sway_server server = {0};
struct sway_debug debug = {0};
char **child_envp;
void sway_terminate(int exit_code) {
if (!server.wl_display) {
@ -348,6 +350,8 @@ int main(int argc, char **argv) {
ipc_init(&server);
setenv("WAYLAND_DISPLAY", server.socket, true);
// g_get_environ creates a newly-allocated environment buffer
child_envp = g_get_environ();
if (!load_main_config(config_path, false, false)) {
sway_terminate(EXIT_FAILURE);
goto shutdown;
@ -381,6 +385,7 @@ shutdown:
free(config_path);
free_config(config);
g_strfreev(child_envp);
pango_cairo_font_map_set_default(NULL);