From 4484e866cbe1d667102e1b58f83b76403a220197 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Thu, 14 Jun 2018 12:05:56 +0100 Subject: [PATCH] terminal: managed to spawn getty on TTYs manually from init --- README.adoc | 47 ++++++++++++++++++++++++++++++++++++++++++- rootfs_overlay/psa.sh | 4 ++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 rootfs_overlay/psa.sh diff --git a/README.adoc b/README.adoc index 9b36d5a..c97dba9 100644 --- a/README.adoc +++ b/README.adoc @@ -3921,6 +3921,26 @@ There are only 4 serial ports, I think this is determined by QEMU. TODO check. + See also: https://stackoverflow.com/questions/16706423/two-instances-of-busybox-on-separate-serial-lines-ttysn +Get the TTY in bulk for all processes: + +.... +/psa.sh +.... + +Source: link:rootfs_overlay/psa.sh[]. + +The TTY appears under the `TT` section, which is enabled by `-o tty`. This shows the TTY device number, e.g.: + +.... +4,1 +.... + +and we can then confirm it with: + +.... +ls -l /dev/tty1 +.... + Next try: .... @@ -3939,7 +3959,9 @@ See also: TODO: https://unix.stackexchange.com/questions/196704/getty-start-from-command-line -If I try the exact same command that the `inittab` is doing from a regular shell: +TODO: how to place an `sh` directly on a TTY as well without `getty`? + +If I try the exact same command that the `inittab` is doing from a regular shell after boot: .... /sbin/getty 0 tty1 @@ -3951,6 +3973,29 @@ it fails with: getty: setsid: Operation not permitted .... +The following however works: + +.... +./run -E 'getty 0 tty1 & getty 0 tty2 & getty 0 tty3 & sleep 99999999' -x +.... + +presumably because it is being called from `init` directly? + +Outcome: `Alt-Right` cycles between three TTYs, `tty1` being the default one that appears under the boot messages. + +`man 2 setsid` says that there is only one failure possibility: + +____ + +EPERM The process group ID of any process equals the PID of the calling process. Thus, in particular, setsid() fails if the calling process is already a process group leader. +____ + +We can get some visibility into it to try and solve the problem with: + +.... +/psa.sh +.... + ===== console kernel boot parameter Take the command described at <> and try adding the following: diff --git a/rootfs_overlay/psa.sh b/rootfs_overlay/psa.sh new file mode 100755 index 0000000..a2a1fbc --- /dev/null +++ b/rootfs_overlay/psa.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# Show All possible ps fields to get better process visibility. +# TODO for some reason nothing shows after args, so we put it last. +ps -o user,group,comm,pid,ppid,sid,pgid,tty,vsz,rss,stat,args