I have an extremely bizarre problem, occurring somewhere at the intersection of terminal, su, w3m and /dev/null:
when I su - from user1 to user2, following command does not work:
$ w3m zz.html 2>/dev/null
Error occurred while reset 800b: errno=25
but the same command works fine without the 2>/dev/null redirection:
$ w3m zz.html
And finally, when I login directly as user2 (instead of switching from user1), everything works fine (both with 2>/dev/null and without)
When I run w3m with strace: strace -o zz.strace w3m zz.html 2>/dev/null, I see the two cases (working and non-working) starting to diverge at this point:
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=77, ws_col=199, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, 0x7318fb8e7c40) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(2, {st_mode=S_IFCHR|0666, st_rdev=makedev(0x1, 0x3), ...}) = 0
ioctl(2, TCGETS, 0x7318fb8e7400) = -1 ENOTTY (Inappropriate ioctl for device)
brk(0x16a51a8a1000) = 0x16a51a8a1000
brk(0x16a51a8b1000) = 0x16a51a8b1000
brk(0x16a51a8c2000) = 0x16a51a8c2000
brk(0x16a51a8d2000) = 0x16a51a8d2000
brk(0x16a51a8e8000) = 0x16a51a8e8000
ioctl(2, TCGETS, 0x7318fb8e7bd0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(2, TCGETS, 0x7318fb8e7bc0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(2, SNDCTL_TMR_START or TCSETS, {B0 -opost -isig -icanon -echo ...}) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x7), ...}) = 0
write(1, "Error occurred while reset 800b:"..., 42) = 42
write(2, "\33[?1049h\33[22;0;0t\33[H\33[2J\33[39;49m"..., 58) = 58
ioctl(2, TCGETS, 0x7318fb8e7ba0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(2, SNDCTL_TMR_START or TCSETS, {B0 -opost -isig -icanon -echo ...}) = -1 ENOTTY (Inappropriate ioctl for device)
exit_group(1) = ?
+++ exited with 1 +++
From what I was able to find, the TIOCGWINSZ ioctl seems to be something related to terminal size. But I am not able to find what exactly is causing this problem.
B0 -opost -isig -icanon -echo ...). That is 0 bps, no output post-processing, no input control character processing, no echoing of input, etc. This fails, followed by a stat of file descriptor 1, the error message to stdout, some escape sequences that look like xterm ones to stderr, a repeat of the call setting raw mode, and finally exit. What are the differences between the working and non-workingstracein the calls:ioctl(2, SNDCTL_TMR_START or TCSETS, {B0 ...?ioctl(2, SNDCTL_TMR_START or TCSETS, {B0 -opost -isig -icanon -echo ...}) = -1 ENOTTY (Inappropriate ioctl for device), vs the working:ioctl(3, SNDCTL_TMR_START or TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0. I have pasted the full straceses here: ctxt.io/2/AAAQPmMeEQ and ctxt.io/2/AAAQPtNaFgls -lZ /dev/nulloutput?ttyoutput shows/dev/pts/21both when run underuser1, as well as after i switched touser2(su - user2). But/dev/pts/21is owned byuser1.