From 0c7ca38c7f8b3da5b3dfa44064fe994c80849b71 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 6 Jun 2012 14:30:18 +0300 Subject: client: require XDG_RUNTIME_DIR An arbitrary fallback to the current directory is only confusing. Signed-off-by: Pekka Paalanen --- src/wayland-client.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/wayland-client.c b/src/wayland-client.c index ecedd99..bba972e 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -308,16 +308,15 @@ connect_to_socket(struct wl_display *display, const char *name) const char *runtime_dir; size_t name_size; - display->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0); - if (display->fd < 0) - return -1; - runtime_dir = getenv("XDG_RUNTIME_DIR"); - if (runtime_dir == NULL) { - runtime_dir = "."; + if (!runtime_dir) { fprintf(stderr, - "XDG_RUNTIME_DIR not set, falling back to %s\n", - runtime_dir); + "error: XDG_RUNTIME_DIR not set in the environment.\n"); + + /* to prevent programs reporting + * "failed to create display: Success" */ + errno = ENOENT; + return -1; } if (name == NULL) @@ -325,6 +324,10 @@ connect_to_socket(struct wl_display *display, const char *name) if (name == NULL) name = "wayland-0"; + display->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0); + if (display->fd < 0) + return -1; + memset(&addr, 0, sizeof addr); addr.sun_family = AF_LOCAL; name_size = -- cgit v1.2.3