After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 656492 - glib has lots of missing handling for EINTR
glib has lots of missing handling for EINTR
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
2.28.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 682819 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-08-14 01:56 UTC by Antoine Jacoutot
Modified: 2018-05-24 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
make g_io_channel_new_file follow POSIX (1.04 KB, patch)
2011-08-14 01:56 UTC, Antoine Jacoutot
committed Details | Review

Description Antoine Jacoutot 2011-08-14 01:56:22 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?
Comment 1 Colin Walters 2011-08-15 07:58:48 UTC
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.
Comment 2 Dan Winship 2011-08-15 12:50:12 UTC
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...
Comment 3 Colin Walters 2011-08-16 08:27:18 UTC
Retitling and reopening.
Comment 4 Matthias Clasen 2013-03-18 03:55:24 UTC
*** Bug 682819 has been marked as a duplicate of this bug. ***
Comment 5 GNOME Infrastructure Team 2018-05-24 13:18:41 UTC
-- 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.