Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.devel.testing > #1030

grep-2.27-1 fails when >/dev/null 2>&1

From Lars Bro <larsbro@gmail.com>
Newsgroups linux.debian.devel.testing
Subject grep-2.27-1 fails when >/dev/null 2>&1
Date 2017-01-03 21:50 +0100
Message-ID <sVEbU-3aT-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi list,

I am using Debian Stretch, obtained with debootstrap (as of Jan 02 2017).
Linux kernel of the host is 4.4.6, and the following is run in a chroot.
File system is ext4.

When I try to run "./configure" of one of the applications I use, it fails,
claiming that gmake is not present.

When looking into the "configure script" I find this construct:

/bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1

And when I test it, I see this:

root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1
root@mini:/# echo $?
2
root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>/dev/null
root@mini:/# echo $?

0
root@mini:/#

There is apparently something that goes wrong when "dup(2)" is used as in
2>&1

I did an strace of the two constructs:
This is the failing:

"/bin/sh -c 'make --version | gre"..., 8192) = 55
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(1, 2)

[pid 11678] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11678] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1
EINVAL
(Invalid argument)


And this one works

read(0,  /bin/sh -c 'make --version | grep GNU' > /dev/null
2>/dev/null
" /bin/sh -c 'make --version | gr"..., 8192) = 64
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 2)                              = 2
close(3)

[pid 11689] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11689] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = 0

This suggests that there is something with the "splice(2)" system call.

I tried with grep_2.25-6 wich was in Stretch before. It works as below:

[pid 11821] <... read resumed> "GNU Make 4.1\nBuilt for x86_64-
pc"...,
32768) = 297
...
[pid 11821] read(0, "", 32768)          = 0
[pid 11821] write(1, "GNU Make 4.1\nLicense GPLv3+: GNU"..., 91) = 91


It seems to work because it uses read(0,...) and write(1,...) instead of
splice().

I could temporarily downgrade grep to that version, but I fear that the
problem may be of a more general nature.

yours,

Lars Bro

Back to linux.debian.devel.testing | Previous | NextNext in thread | Find similar


Thread

grep-2.27-1 fails when >/dev/null 2>&1 Lars Bro <larsbro@gmail.com> - 2017-01-03 21:50 +0100
  Re: grep-2.27-1 fails when >/dev/null 2>&1 Adrian Bunk <bunk@debian.org> - 2017-01-15 23:10 +0100

csiph-web