diff --git a/unix/uxpty.c b/unix/uxpty.c index 0c7e820c..2f182b43 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -1113,9 +1113,13 @@ Backend *pty_backend_create( * on. */ const char *x_display = seat_get_x_display(pty->seat); - char *x_display_env_var = dupprintf("DISPLAY=%s", x_display); - putenv(x_display_env_var); - /* As above, we don't free this. */ + if (x_display) { + char *x_display_env_var = dupprintf("DISPLAY=%s", x_display); + putenv(x_display_env_var); + /* As above, we don't free this. */ + } else { + unsetenv("DISPLAY"); + } } #endif {