From 7e685eaa4c8a2483a9d0152f47fdb1b70d6ccfec Mon Sep 17 00:00:00 2001 From: Reginald Kennedy Date: Wed, 4 May 2016 22:10:14 +0800 Subject: [PATCH] Prepend SWM_LIB to LD_PRELOAD instead of clobbering. closes #124 --- spectrwm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spectrwm.c b/spectrwm.c index 37b0d2e..e566741 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -3712,7 +3712,16 @@ spawn(int ws_idx, union arg *args, bool close_fd) close(xcb_get_file_descriptor(conn)); - setenv("LD_PRELOAD", SWM_LIB, 1); + if ((ret = getenv("LD_PRELOAD"))) { + if (asprintf(&ret, "%s:%s", SWM_LIB, ret) == -1) { + warn("spawn: asprintf LD_PRELOAD"); + _exit(1); + } + setenv("LD_PRELOAD", ret, 1); + free(ret); + } else { + setenv("LD_PRELOAD", SWM_LIB, 1); + } if (asprintf(&ret, "%d", ws_idx) == -1) { warn("spawn: asprintf SWM_WS"); -- 2.39.2