[systemd-devel] systemd does not shutdown system, it is waiting for a serial tty to show up

Hans de Goede hdegoede at redhat.com
Mon Mar 16 11:32:03 PDT 2015


Hi,

On 16-03-15 18:12, David Herrmann wrote:
> Hi Hans
>
> On Mon, Mar 16, 2015 at 5:15 PM, Hans de Goede <hdegoede at redhat.com> wrote:
>> Hi,
>>
>> On some of the ARM boards I work on in my spare time I've
>> done "systemctl enable getty at ttyGS0.service" to get a getty
>> on the usb gadget serial port which I've configured on the
>> devices otg controller.
>>
>> This serial port device node /dev/ttyGS0 shows up as soon
>> as the gadget serial port driver loads, but is only usable
>> when I plug in a the mini B end of a mini B -> A usb cable
>> where the A end is plugged into an active usb host.
>>
>> "ps aux" shows something peculiar here, when I do "ps aux"
>> before the cable is plugged in it shows "(agetty)" in
>> the args column of the output, when I then plug in the
>> cable the output changes to "/sbin/agetty --noclear ttyGS0 vt220"
>> note this is the same process, as before the cable was plugged,
>> I've a feeling that somehow the process is stuck halfway
>> exec or some such ... ??
>
> We rename the process to "(<file>)" directly after fork(). So if it is
> still "(agetty)", something blocks before we can exec(). Can you run
> strace to figure out what call blocks?

strace -p<pid> says:

write(3, "\33[r\33[H\33[2J", 10

And then when I plug in the cable (the ") = 10" is the write finishing) :

)        = 10
close(3)                                = 0
open("/dev/null", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 3
dup2(3, 0)                              = 0
close(3)                                = 0
socket(PF_LOCAL, SOCK_STREAM, 0)        = 3
connect(3, {sa_family=AF_LOCAL, sun_path="/run/systemd/journal/stdout"}, 29) = 0
shutdown(3, SHUT_RD)                    = 0
getsockopt(3, SOL_SOCKET, SO_SNDBUF, [163840], [4]) = 0
setsockopt(3, SOL_SOCKET, SO_SNDBUFFORCE, [8388608], 4) = 0
fstat64(3, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
_llseek(3, 0, 0xbee70fc8, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(3, "agetty\ngetty at ttyGS0.service\n30\n1"..., 39) = 39
munmap(0xb6e0f000, 4096)                = 0
dup2(3, 1)                              = 1
close(3)                                = 0
dup2(1, 2)                              = 2
fstatat64(AT_FDCWD, "/sys/fs/cgroup/systemd", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/systemd/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpu", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpu/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpu", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpu/system.slice/system-getty.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpu", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpu/system.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpuacct", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpuacct/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpuacct", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpuacct/system.slice/system-getty.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/cpuacct", {st_mode=S_IFLNK|0777, st_size=11, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/cpuacct/system.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
fstatat64(AT_FDCWD, "/sys/fs/cgroup/blkio", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/blkio/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/blkio", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/blkio/system.slice/system-getty.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/blkio", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/blkio/system.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
fstatat64(AT_FDCWD, "/sys/fs/cgroup/memory", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/memory/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/memory", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/memory/system.slice/system-getty.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/memory", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/memory/system.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
fstatat64(AT_FDCWD, "/sys/fs/cgroup/devices", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/devices/system.slice/system-getty.slice/getty at ttyGS0.service/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
fstatat64(AT_FDCWD, "/sys/fs/cgroup/devices", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
open("/sys/fs/cgroup/devices/system.slice/system-getty.slice/cgroup.procs", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_GETFL)                     = 0x20001 (flags O_WRONLY|O_LARGEFILE)
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e0f000
write(3, "379\n", 4)                    = 4
close(3)                                = 0
munmap(0xb6e0f000, 4096)                = 0
getsid(0)                               = 379
clock_gettime(CLOCK_REALTIME, {1426530281, 697533469}) = 0
access("/var/run/utmpx", F_OK)          = -1 ENOENT (No such file or directory)
open("/var/run/utmp", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
_llseek(3, 0, [0], SEEK_SET)            = 0
access("/var/run/utmpx", F_OK)          = -1 ENOENT (No such file or directory)
open("/var/run/utmp", O_RDWR|O_LARGEFILE|O_CLOEXEC) = 4
_llseek(3, 0, [0], SEEK_CUR)            = 0
_llseek(4, 0, [0], SEEK_SET)            = 0
dup2(4, 3)                              = 3
close(4)                                = 0
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 0}}, {it_interval={0, 0

And then a lot more cgroup, utmp, wtmp, etc. setup followed by a whole bunch
of ugetrlimit calls and then finally:

execve("/sbin/agetty", ["/sbin/agetty", "--noclear", "ttyGS0", "vt220"], [/* 16 vars */]) = 0

So your right that this is before executing agetty

> Furthermore, what state is the process in?

Ss (ps aux state) looks like it blocks on a write to the not yet ready for use tty.

> Thanks

You're welcome and thanks for looking into this.

Regards,

Hans

> David
>
>> If I plug in the cable I get a getty on the other end of
>> the usb gadget serial connection and everything more or less
>> works. I say more or less because it seems that part of
>> the welcome header from getty gets lost, and sometimes getty
>> acts as if it has received some garbage on its stdin. I mention
>> this because it may be related, but it may also very well be a
>> bug in the usb stack somewhere.
>>
>> The problem which I have why I'm sending this mail is that
>> halt (-p) or reboot does not work when there is no usb cable
>> plugged into the otg connector.
>>
>> "halt -p" just sits there for a long time, and then exits with
>> a dbus timeout error. If I plug in the cable while it is doing
>> this, then it continues and starts shutting down.
>>
>> Regards,
>>
>> Hans
>> _______________________________________________
>> systemd-devel mailing list
>> systemd-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list