@jonasas

Как починить less?

Доброго времени суток. У меня на сервере (Debian 6) в какой-то момент сломался less.
При любой попытке что-либо прочитать (файл или stdin) он просто закрывается.
Как я понял, что-то не так с ioctl. Возможно, он не может найти stdout моего терминала.
Вот вывод strace:
strace less file.txt 
execve("/usr/bin/less", ["less", "file.txt"], [/* 31 vars */]) = 0
brk(0)                                  = 0x1f61000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f91fa6f2000
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=50899, ...}) = 0
mmap(NULL, 50899, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f91fa6e5000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libncurses.so.5", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20*\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=286776, ...}) = 0
mmap(NULL, 2383488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f91fa291000
mprotect(0x7f91fa2d3000, 2093056, PROT_NONE) = 0
mmap(0x7f91fa4d2000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x41000) = 0x7f91fa4d2000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\355\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1465768, ...}) = 0
mmap(NULL, 3573832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f91f9f28000
mprotect(0x7f91fa088000, 2093056, PROT_NONE) = 0
mmap(0x7f91fa287000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15f000) = 0x7f91fa287000
mmap(0x7f91fa28c000, 18504, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f91fa28c000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libdl.so.2", O_RDONLY)       = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14696, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f91fa6e4000
mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f91f9d24000
mprotect(0x7f91f9d26000, 2097152, PROT_NONE) = 0
mmap(0x7f91f9f26000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f91f9f26000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f91fa6e3000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f91fa6e2000
arch_prctl(ARCH_SET_FS, 0x7f91fa6e3700) = 0
mprotect(0x7f91f9f26000, 4096, PROT_READ) = 0
mprotect(0x7f91fa287000, 16384, PROT_READ) = 0
mprotect(0x7f91fa6f4000, 4096, PROT_READ) = 0
munmap(0x7f91fa6e5000, 50899)           = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
brk(0)                                  = 0x1f61000
brk(0x1f82000)                          = 0x1f82000
stat("/root/.terminfo", 0x7fff82a97c20) = -1 ENOENT (No such file or directory)
stat("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/etc/terminfo/x/xterm", R_OK)   = -1 ENOENT (No such file or directory)
stat("/lib/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/lib/terminfo/x/xterm", R_OK)   = 0
open("/lib/terminfo/x/xterm", O_RDONLY) = 3
read(3, "\32\1\34\0&\0\17\0\235\1Z\5xterm|X11 terminal e"..., 4097) = 3213
close(3)                                = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=38, ws_col=168, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=38, ws_col=168, ws_xpixel=0, ws_ypixel=0}) = 0
open("/usr/bin/.sysless", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/etc/sysless", O_RDONLY)          = -1 ENOENT (No such file or directory)
open("/root/.less", O_RDONLY)           = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=108805904, ...}) = 0
mmap(NULL, 108805904, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f91f3560000
close(3)                                = 0
open("/root/.lesshst", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=407, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f91fa6f1000
read(3, ".less-history-file:\n.search\n\"scr"..., 4096) = 407
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f91fa6f1000, 4096)            = 0
open("/dev/tty", O_RDONLY)              = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff82a99560) = -1 ENOTTY (Inappropriate ioctl for device)
fsync(3)                                = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff82a99520) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, SNDCTL_TMR_STOP or TCSETSW, {B2000000 opost -isig -icanon -echo ...}) = -1 ENOTTY (Inappropriate ioctl for device)
rt_sigaction(SIGINT, {0x414690, [INT], SA_RESTORER|SA_RESTART, 0x7f91f9f59f50}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTSTP, {0x414610, [TSTP], SA_RESTORER|SA_RESTART, 0x7f91f9f59f50}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGWINCH, {0x414650, [WINCH], SA_RESTORER|SA_RESTART, 0x7f91f9f59f50}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [QUIT], SA_RESTORER|SA_RESTART, 0x7f91f9f59f50}, {SIG_DFL, [], 0}, 8) = 0
stat("file.txt", {st_mode=S_IFREG|0644, st_size=18, ...}) = 0
stat("file.txt", {st_mode=S_IFREG|0644, st_size=18, ...}) = 0
open("file.txt", O_RDONLY)              = 4
lseek(4, 1, SEEK_SET)                   = 1
lseek(4, 0, SEEK_SET)                   = 0
read(4, "line1\nline2\nline3\n", 256)   = 18
lseek(4, 1, SEEK_SET)                   = 1
fstat(4, {st_mode=S_IFREG|0644, st_size=18, ...}) = 0
lseek(4, 0, SEEK_SET)                   = 0
stat("file.txt", {st_mode=S_IFREG|0644, st_size=18, ...}) = 0
write(1, "\33[?1049h\33[?1h\33=\r", 16) = 19
fsync(3)                                = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff82a993a0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, SNDCTL_TMR_STOP or TCSETSW, {B2000000 -opost -isig -icanon -echo ...}) = -1 ENOTTY (Inappropriate ioctl for device)
exit_group(1)                           = ?

Все остальные утилиты чтения/редактирования работают нормально (more, vim, nano, cat)
Не могу понять, куда копать, помогите, пожалуйста!
  • Вопрос задан
  • 482 просмотра
Решения вопроса 1
jcmvbkbc
@jcmvbkbc
http://dilbert.com/strip/1998-08-24
open("/dev/tty", O_RDONLY) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff82a99560) = -1 ENOTTY (Inappropriate ioctl for device)

У вас кажется /dev/tty сломался.
Что говорит stat /dev/tty
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы