Showing with 18 additions and 8 deletions.
  1. +1 −1 meson.build
  2. +3 −0 src/types/copy-action.c
  3. +9 −7 src/types/registry.c
  4. +5 −0 src/util/files.c
2 changes: 1 addition & 1 deletion meson.build
@@ -1,5 +1,5 @@
project('wl-clipboard', 'c',
version: '2.2.0',
version: '2.2.1',
license: 'GPL-3.0-or-later',
meson_version: '>= 0.47.0',
default_options: 'c_std=gnu99'
Expand Down
3 changes: 3 additions & 0 deletions src/types/copy-action.c
Expand Up @@ -30,6 +30,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>

static void do_set_selection(struct copy_action *self, uint32_t serial) {
/* Set the selection and make sure it reaches
Expand Down Expand Up @@ -86,6 +87,8 @@ static void do_send(struct source *source, const char *mime_type, int fd) {
close(self->fd_to_copy_from);
dup2(fd, STDOUT_FILENO);
close(fd);
signal(SIGHUP, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
execlp("cat", "cat", NULL);
perror("exec cat");
exit(1);
Expand Down
16 changes: 9 additions & 7 deletions src/types/registry.c
Expand Up @@ -29,12 +29,14 @@

#define BIND(interface_name, known_version) \
if (strcmp(interface, #interface_name) == 0) { \
self->interface_name = wl_registry_bind( \
wl_registry, \
name, \
&interface_name ## _interface, \
known_version \
); \
if (version >= (known_version)) { \
self->interface_name = wl_registry_bind( \
wl_registry, \
name, \
&interface_name ## _interface, \
known_version \
); \
} \
}

static void wl_registry_global_handler(
Expand Down Expand Up @@ -81,7 +83,7 @@ static void wl_registry_global_handler(
BIND(zwlr_data_control_manager_v1, version > 2 ? 2 : version)
#endif

if (strcmp(interface, "wl_seat") == 0) {
if (strcmp(interface, "wl_seat") == 0 && version >= 2) {
struct seat *seat = calloc(1, sizeof(struct seat));
seat->proxy = wl_registry_bind(
wl_registry,
Expand Down
5 changes: 5 additions & 0 deletions src/util/files.c
Expand Up @@ -33,6 +33,7 @@
#include <stdlib.h> // exit
#include <libgen.h> // basename
#include <sys/wait.h>
#include <signal.h>
#include <syslog.h>

#ifdef HAVE_MEMFD
Expand Down Expand Up @@ -167,6 +168,8 @@ char *infer_mime_type_from_contents(const char *file_path) {
/* If we cannot open /dev/null, just close stdin */
close(STDIN_FILENO);
}
signal(SIGHUP, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
execlp("xdg-mime", "xdg-mime", "query", "filetype", file_path, NULL);
exit(1);
}
Expand Down Expand Up @@ -274,6 +277,8 @@ char *dump_stdin_into_a_temp_file() {
}
dup2(fd, STDOUT_FILENO);
close(fd);
signal(SIGHUP, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
execlp("cat", "cat", NULL);
perror("exec cat");
exit(1);
Expand Down