bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Internal 'echo' command doesn't handle I/O errors on close file


From: Andrey Zaitsev
Subject: Internal 'echo' command doesn't handle I/O errors on close file
Date: Mon, 23 Apr 2012 14:38:47 +0400

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE
-DRECYCLES_PIDS  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fwrapv
uname output: Linux dhcp-10-30-20-255.sw.ru 2.6.32-042stab054.1 #1 SMP Fri
Mar 30 01:41:10 MSD 2012 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.1
Patch Level: 2
Release Status: release

Description:
Internal 'echo' command doesn't handle I/O errors on close file when I try
redirect
standart output to mounted filesystem without free space.

Try redirect stdout of echo command to mounted filesystem without free space
address@hidden ~]# echo "bla-bla-bla" > /mnt/fs/out.txt
address@hidden ~]# echo $?
0
i.e. it means that all ok, but operation was failed.

Try the same action for /bin/echo
address@hidden ~]# /bin/echo "bla-bla-bla" > /mnt/fs/out.txt
/bin/echo: write error: No space left on device
address@hidden ~]# echo $?
1
valid behaviour

Strace show that errors from /bin/bash were ignored:

address@hidden ~]# strace echo "bla-bla-bla" > /mnt/fs/out.txt
execve("/bin/echo", ["echo", "bla-bla-bla"], [/* 22 vars */]) = 0
brk(0)                                  = 0x2467000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d362000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=36827, ...}) = 0
mmap(NULL, 36827, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f766d359000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3,
"\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355!b2\0\0\0"..., 832)
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1979000, ...}) = 0
mmap(0x3262200000, 3803304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x3262200000
mprotect(0x3262397000, 2097152, PROT_NONE) = 0
mmap(0x3262597000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x197000) = 0x3262597000
mmap(0x326259c000, 18600, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x326259c000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d358000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d357000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d356000
arch_prctl(ARCH_SET_FS, 0x7f766d357700) = 0
mprotect(0x3262597000, 16384, PROT_READ) = 0
mprotect(0x326201f000, 4096, PROT_READ) = 0
munmap(0x7f766d359000, 36827)           = 0
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=99158704, ...}) = 0
mmap(NULL, 99158704, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f76674c5000
close(3)                                = 0
brk(0)                                  = 0x2467000
brk(0x2488000)                          = 0x2488000
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2512, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d361000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2512
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f766d361000, 4096)            = 0
open("/usr/lib/locale/posix/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
fstat(1, {st_mode=S_IFREG|0700, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f766d361000
write(1, "bla-bla-bla\n", 12)           = 12
close(1)                                = -1 ENOSPC (No space left on
device)
munmap(0x7f766d361000, 4096)            = 0
write(2, "echo: ", 6echo: )                   = 6
write(2, "write error", 11write error)             = 11
write(2, ": No space left on device", 25: No space left on device) = 25
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]