zsh-users
 help / color / mirror / code / Atom feed
* serial console
@ 2009-03-14 18:31 Maciej Kazulak
  2009-03-14 18:55 ` Andrey Borzenkov
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Kazulak @ 2009-03-14 18:31 UTC (permalink / raw)
  To: zsh-users

Hi,

Zsh seems to fail to properly start on a serial console. Let's see:
- it works fine with bash
- im using minicom to directly connect through a nullmodem cable
- my laptop doesn't have a serial port so i have to use a usb to
serial converter (pl2303)
- machine i connect to: Linux box 2.6.28-gentoo #4 SMP Thu Feb 26
19:45:52 CET 2009 x86_64 Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz
GenuineIntel GNU/Linux
- zsh --version: zsh 4.3.9 (x86_64-pc-linux-gnu)
- also tested with 4.3.4-r1 - latest version marked stable in portage

Config:

/etc/inittab:
s1:12345:respawn:/sbin/agetty -f /etc/issueserial ttyS1 38400 vt102

/etc/securetty:
(...)
ttyS1
(...)

I've been using zsh as my primary shell for a few years now and i had
no issues so far not on the box i connect to (or any other). Obviously
my regular user has a shell set to /bin/zsh. When i start minicom
/etc/issueserial is printed and a login prompt appears. I input my
username/password and i can see a "Last login..." line. After that it
just hangs. In particular no shell prompt is printed no matter how
long i wait.

When i login as root (shell is /bin/bash) it works fine without any
delays. If i then try to start zsh from bash it hangs just like above.

"strace zsh" from bash:

execve("/bin/zsh", ["zsh"], [/* 43 vars */]) = 0
brk(0)                                  = 0x2114000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e5e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e5d000
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=171220, ...}) = 0
mmap(NULL, 171220, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8591e33000
close(3)                                = 0
open("/usr/lib/libpcre.so.0", 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\360\27\0\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=194520, ...}) = 0
mmap(NULL, 2289904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f8591a10000
mprotect(0x7f8591a3f000, 2093056, PROT_NONE) = 0
mmap(0x7f8591c3e000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2e000) = 0x7f8591c3e000
close(3)                                = 0
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\360\r\0\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=14512, ...}) = 0
mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f859180c000
mprotect(0x7f859180e000, 2097152, PROT_NONE) = 0
mmap(0x7f8591a0e000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f8591a0e000
close(3)                                = 0
open("/lib/libnsl.so.1", 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\320@\0\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=97072, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e32000
mmap(NULL, 2202320, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f85915f2000
mprotect(0x7f8591608000, 2097152, PROT_NONE) = 0
mmap(0x7f8591808000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f8591808000
mmap(0x7f859180a000, 6864, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f859180a000
close(3)                                = 0
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\200
\2\0\0\0\0\0@"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=392112, ...}) = 0
mmap(NULL, 2490536, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f8591391000
mprotect(0x7f85913e3000, 2093056, PROT_NONE) = 0
mmap(0x7f85915e2000, 61440, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x51000) = 0x7f85915e2000
mmap(0x7f85915f1000, 168, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f85915f1000
close(3)                                = 0
open("/lib/libm.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\200>\0\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=542840, ...}) = 0
mmap(NULL, 2638040, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f859110c000
mprotect(0x7f8591190000, 2093056, PROT_NONE) = 0
mmap(0x7f859138f000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x83000) = 0x7f859138f000
close(3)                                = 0
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\360\346\1\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1506480, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e31000
mmap(NULL, 3613336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f8590d99000
mprotect(0x7f8590f02000, 2097152, PROT_NONE) = 0
mmap(0x7f8591102000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x169000) = 0x7f8591102000
mmap(0x7f8591107000, 17048, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8591107000
close(3)                                = 0
open("/lib/libz.so.1", 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
\0\0\0\0\0\0@"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=88368, ...}) = 0
mmap(NULL, 2183664, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f8590b83000
mprotect(0x7f8590b98000, 2093056, PROT_NONE) = 0
mmap(0x7f8590d97000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f8590d97000
close(3)                                = 0
open("/lib/libbz2.so.1", 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\30\0\0\0\0\0\0@"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=66736, ...}) = 0
mmap(NULL, 2162032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f8590973000
mprotect(0x7f8590982000, 2093056, PROT_NONE) = 0
mmap(0x7f8590b81000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f8590b81000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e30000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f8591e2f000
arch_prctl(ARCH_SET_FS, 0x7f8591e2f6f0) = 0
mprotect(0x7f8590b81000, 4096, PROT_READ) = 0
mprotect(0x7f8590d97000, 4096, PROT_READ) = 0
mprotect(0x7f8591102000, 16384, PROT_READ) = 0
mprotect(0x7f859138f000, 4096, PROT_READ) = 0
mprotect(0x7f85915e2000, 53248, PROT_READ) = 0
mprotect(0x7f8591808000, 4096, PROT_READ) = 0
mprotect(0x7f8591a0e000, 4096, PROT_READ) = 0
mprotect(0x7f8591c3e000, 4096, PROT_READ) = 0
mprotect(0x68f000, 4096, PROT_READ)     = 0
mprotect(0x7f8591e5f000, 4096, PROT_READ) = 0
munmap(0x7f8591e33000, 171220)          = 0
brk(0)                                  = 0x2114000
brk(0x2135000)                          = 0x2135000
open("/usr/lib64/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1916304, ...}) = 0
mmap(NULL, 1916304, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f859079f000
close(3)                                = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
fcntl(64, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(65, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(66, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(67, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(68, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(69, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(70, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(71, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(72, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(73, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(74, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(75, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(76, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(77, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(78, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(79, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(80, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(81, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(82, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(83, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(84, F_GETFL)                      = -1 EBADF (Bad file descriptor)
fcntl(85, F_GETFL)                      = -1 EBADF (Bad file descriptor)
(...)
fcntl(1020, F_GETFL)                    = -1 EBADF (Bad file descriptor)
fcntl(1021, F_GETFL)                    = -1 EBADF (Bad file descriptor)
fcntl(1022, F_GETFL)                    = -1 EBADF (Bad file descriptor)
fcntl(1023, F_GETFL)                    = -1 EBADF (Bad file descriptor)
getuid()                                = 0
geteuid()                               = 0
getgid()                                = 0
getegid()                               = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
readlink("/proc/self/fd/0", "/dev/ttyS1"..., 4095) = 10
open("/dev/ttyS1", O_RDWR|O_NOCTTY

And it stops there.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial console
  2009-03-14 18:31 serial console Maciej Kazulak
@ 2009-03-14 18:55 ` Andrey Borzenkov
  2009-03-14 19:15   ` Maciej Kazulak
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2009-03-14 18:55 UTC (permalink / raw)
  To: zsh-users; +Cc: Maciej Kazulak

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

On 14 марта 2009 21:31:59 Maciej Kazulak wrote:
> ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon
> echo ...}) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost
> isig icanon echo ...}) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS,
> {B38400 opost isig icanon echo ...}) = 0 readlink("/proc/self/fd/0",
> "/dev/ttyS1"..., 4095) = 10
> open("/dev/ttyS1", O_RDWR|O_NOCTTY
>
> And it stops there.

Which implies, that

- terminal is in -clocal mode
- carrier detect signal is not present

There are two issues here

- OS seems to lie. In -clocal mode lack of carrier detect should result 
in HUP signal and no communication should be possible.

- should zsh really reopen terminal? If we need additional fd, it could 
just dup() it?

Interesting, Mandriva RPM has patch that opens tty with O_NONBLOCK; 
presumably exactly to work around this issue. I am still not convinced 
that it is the right way; I would really like to understand what happens 
with tty driver. Could you dump full contents of struct termios *? I 
believe in Linux it should be something like

strace -e verbose=ioctl ...

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial console
  2009-03-14 18:55 ` Andrey Borzenkov
@ 2009-03-14 19:15   ` Maciej Kazulak
  2009-03-14 19:44     ` Andrey Borzenkov
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Kazulak @ 2009-03-14 19:15 UTC (permalink / raw)
  To: zsh-users

2009/3/14 Andrey Borzenkov <arvidjaar@gmail.com>:
> Interesting, Mandriva RPM has patch that opens tty with O_NONBLOCK;
> presumably exactly to work around this issue. I am still not convinced
> that it is the right way; I would really like to understand what happens
> with tty driver. Could you dump full contents of struct termios *? I
> believe in Linux it should be something like
>
> strace -e verbose=ioctl ...
>

Here you go.

strace -v zsh:
fcntl(1023, F_GETFL)                    = -1 EBADF (Bad file descriptor)
getuid()                                = 0
geteuid()                               = 0
getgid()                                = 0
getegid()                               = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0x4bf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0x4bf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0x4bf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
readlink("/proc/self/fd/0", "/dev/ttyS1"..., 4095) = 10
open("/dev/ttyS1", O_RDWR|O_NOCTTY


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial console
  2009-03-14 19:15   ` Maciej Kazulak
@ 2009-03-14 19:44     ` Andrey Borzenkov
  2009-03-14 19:53       ` Maciej Kazulak
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2009-03-14 19:44 UTC (permalink / raw)
  To: zsh-users; +Cc: Maciej Kazulak

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

On 14 марта 2009 22:15:12 Maciej Kazulak wrote:
> 2009/3/14 Andrey Borzenkov <arvidjaar@gmail.com>:
> > Interesting, Mandriva RPM has patch that opens tty with O_NONBLOCK;
> > presumably exactly to work around this issue. I am still not
> > convinced that it is the right way; I would really like to
> > understand what happens with tty driver. Could you dump full
> > contents of struct termios *?

> ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
> c_oflags=0x5, c_cflags=0x4bf, c_lflags=0x83b, c_line=0,
> c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x1
>6\x00\x00\x00"}) = 0

Yes, CLOCAL is cleared. What happens if you add -L to agetty parameters?

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial console
  2009-03-14 19:44     ` Andrey Borzenkov
@ 2009-03-14 19:53       ` Maciej Kazulak
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej Kazulak @ 2009-03-14 19:53 UTC (permalink / raw)
  To: zsh-users

2009/3/14 Andrey Borzenkov <arvidjaar@gmail.com>:
> On 14 марта 2009 22:15:12 Maciej Kazulak wrote:
>> 2009/3/14 Andrey Borzenkov <arvidjaar@gmail.com>:
>> > Interesting, Mandriva RPM has patch that opens tty with O_NONBLOCK;
>> > presumably exactly to work around this issue. I am still not
>> > convinced that it is the right way; I would really like to
>> > understand what happens with tty driver. Could you dump full
>> > contents of struct termios *?
>
>> ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
>> c_oflags=0x5, c_cflags=0x4bf, c_lflags=0x83b, c_line=0,
>> c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x1
>>6\x00\x00\x00"}) = 0
>
> Yes, CLOCAL is cleared. What happens if you add -L to agetty parameters?
>

Oh, that does it:

fcntl(1023, F_GETFL)                    = -1 EBADF (Bad file descriptor)
getuid()                                = 0
geteuid()                               = 0
getgid()                                = 0
getegid()                               = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0xcbf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0xcbf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x1500,
c_oflags=0x5, c_cflags=0xcbf, c_lflags=0x83b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
= 0
readlink("/proc/self/fd/0", "/dev/ttyS1"..., 4095) = 10
open("/dev/ttyS1", O_RDWR|O_NOCTTY)     = 3
fcntl(3, F_DUPFD, 10)                   = 10
close(3)                                = 0

And it finally works. Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-14 19:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-14 18:31 serial console Maciej Kazulak
2009-03-14 18:55 ` Andrey Borzenkov
2009-03-14 19:15   ` Maciej Kazulak
2009-03-14 19:44     ` Andrey Borzenkov
2009-03-14 19:53       ` Maciej Kazulak

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).