aboutsummaryrefslogtreecommitdiff
path: root/src/xz/file_io.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-02-22 19:38:48 +0200
committerLasse Collin <lasse.collin@tukaani.org>2015-02-22 19:38:48 +0200
commit7a11c4a8e5e15f13d5fa59233b3172e65428efdd (patch)
treeb4892d6e7c7bd5bc1e462a6154308baec2070f74 /src/xz/file_io.c
parentliblzma: Fix a compression-ratio regression in LZMA1/2 in fast mode. (diff)
downloadxz-7a11c4a8e5e15f13d5fa59233b3172e65428efdd.tar.xz
xz: Use pipe2() if available.
Diffstat (limited to '')
-rw-r--r--src/xz/file_io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c
index 9bd515dd..20f512a2 100644
--- a/src/xz/file_io.c
+++ b/src/xz/file_io.c
@@ -82,7 +82,13 @@ io_init(void)
// we are root.
warn_fchown = geteuid() == 0;
- // Create a pipe for the self-pipe trick.
+ // Create a pipe for the self-pipe trick. If pipe2() is available,
+ // we can avoid the fcntl() calls.
+# ifdef HAVE_PIPE2
+ if (pipe2(user_abort_pipe, O_NONBLOCK))
+ message_fatal(_("Error creating a pipe: %s"),
+ strerror(errno));
+# else
if (pipe(user_abort_pipe))
message_fatal(_("Error creating a pipe: %s"),
strerror(errno));
@@ -95,6 +101,7 @@ io_init(void)
message_fatal(_("Error creating a pipe: %s"),
strerror(errno));
}
+# endif
#endif
#ifdef __DJGPP__