summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-07-12 22:36:42 +0200
committerCarlos Garnacho <carlosg@gnome.org>2017-07-14 12:34:29 +0200
commit0159efe34bfda8acd58aab31ff49b6012e5ed700 (patch)
tree7de6cf153ab94550c026570bdd2da285b7fbf941
parent9f68507f0c3623d86ab552cf788ec05036f67f69 (diff)
downloadmutter-0159efe34bfda8acd58aab31ff49b6012e5ed700.tar.gz
backends: Set error when opening /sys file fails
The caller in clutter really expects an error if fd==-1, so make sure we set one here. Otherwise we get a nice crash in addition to the failure to open the /sys file. Also, retry on EINTR. https://bugzilla.gnome.org/show_bug.cgi?id=784881
-rw-r--r--src/backends/native/meta-launcher.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c
index 4a9a7276e..90b4b98ba 100644
--- a/src/backends/native/meta-launcher.c
+++ b/src/backends/native/meta-launcher.c
@@ -188,9 +188,22 @@ on_evdev_device_open (const char *path,
/* Allow readonly access to sysfs */
if (g_str_has_prefix (path, "/sys/"))
{
- fd = open (path, flags);
- if (fd >= 0)
- g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd));
+ do
+ {
+ fd = open (path, flags);
+ }
+ while (fd < 0 && errno == EINTR);
+
+ if (fd < 0)
+ {
+ g_set_error (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "Could not open /sys file: %s: %m", path);
+ return -1;
+ }
+
+ g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd));
return fd;
}