GNOME Bugzilla – Bug 656492
glib has lots of missing handling for EINTR
Last modified: 2018-05-24 13:18:41 UTC
Created attachment 193799 [details] [review] make g_io_channel_new_file follow POSIX Hi. Kurt Miller from OpenBSD found an issue with glib while working on porting IcedTea-Web/openjdk (Error: Failed to create output channel: Interrupted system call). g_io_channel_new_file() is used to create a plugin-to-appletviewer channel and fails. Posix allows for open(2) to fail with errno = EINTR. Normal this isn't seen when opening files. However in some case we are opening a fifo for write which will block until another process opens it for read. If a signal is received while blocked, open(2) fails with errno = EINTR. Using a small test program showed that a signal received while open(2) is blocked will return EINTR on at least OpenBSD, FreeBSD, Mac OS X and Solaris; so it seems only linux ignores the signal. Here's Kurt's patch to fix the issue. Thoughts?
While this patch looks fine, a simple: git grep ' open (' reveals a lot of other similar bugs. We could possibly make a TEMP_FAILURE_RETRY macro in glibc style, or wrap each one with functions like __g_open() __g_read() that handle EINTR. Yeah, Unix sucks.
having (public) gssize g_read (gint fd, gpointer buf, gsize count) { gssize nread; do nread = read (fd, buf, count); while (nread == -1 && errno == EINTR); return nread; } etc, could be cool...
Retitling and reopening.
*** Bug 682819 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/439.