diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-02-11 03:59:11 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-02-11 10:11:41 +0100 |
commit | 2540e8ea792f7b2a54698aba34b3bf11161fe102 (patch) | |
tree | 5130af706e651c60198522070723270c9e2c78ec | |
parent | fix misc memory leaks (diff) | |
download | sway-2540e8ea792f7b2a54698aba34b3bf11161fe102.tar.gz sway-2540e8ea792f7b2a54698aba34b3bf11161fe102.tar.zst sway-2540e8ea792f7b2a54698aba34b3bf11161fe102.zip |
Abort early when XDG_RUNTIME_DIR is not set
This aborts sway and displays an error message about XDG_RUNTIME_DIR
not being set without initializing the wl_display or logging any other
information.
-rw-r--r-- | sway/main.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sway/main.c b/sway/main.c index 12f92bd8..b118a182 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -299,6 +299,14 @@ int main(int argc, char **argv) { | |||
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | // Since wayland requires XDG_RUNTIME_DIR to be set, abort with just the | ||
303 | // clear error message (when not running as an IPC client). | ||
304 | if (!getenv("XDG_RUNTIME_DIR") && optind == argc) { | ||
305 | fprintf(stderr, | ||
306 | "XDG_RUNTIME_DIR is not set in the environment. Aborting.\n"); | ||
307 | exit(EXIT_FAILURE); | ||
308 | } | ||
309 | |||
302 | // As the 'callback' function for wlr_log is equivalent to that for | 310 | // As the 'callback' function for wlr_log is equivalent to that for |
303 | // sway, we do not need to override it. | 311 | // sway, we do not need to override it. |
304 | if (debug) { | 312 | if (debug) { |