aboutsummaryrefslogtreecommitdiff
path: root/shell/cttyhack.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/cttyhack.c')
-rw-r--r--shell/cttyhack.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 9a5f4bb52..9004b4763 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -14,45 +14,45 @@
14//config: bool "cttyhack (2.5 kb)" 14//config: bool "cttyhack (2.5 kb)"
15//config: default y 15//config: default y
16//config: help 16//config: help
17//config: One common problem reported on the mailing list is the "can't 17//config: One common problem reported on the mailing list is the "can't
18//config: access tty; job control turned off" error message, which typically 18//config: access tty; job control turned off" error message, which typically
19//config: appears when one tries to use a shell with stdin/stdout on 19//config: appears when one tries to use a shell with stdin/stdout on
20//config: /dev/console. 20//config: /dev/console.
21//config: This device is special - it cannot be a controlling tty. 21//config: This device is special - it cannot be a controlling tty.
22//config: 22//config:
23//config: The proper solution is to use the correct device instead of 23//config: The proper solution is to use the correct device instead of
24//config: /dev/console. 24//config: /dev/console.
25//config: 25//config:
26//config: cttyhack provides a "quick and dirty" solution to this problem. 26//config: cttyhack provides a "quick and dirty" solution to this problem.
27//config: It analyzes stdin with various ioctls, trying to determine whether 27//config: It analyzes stdin with various ioctls, trying to determine whether
28//config: it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line). 28//config: it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
29//config: On Linux it also checks sysfs for a pointer to the active console. 29//config: On Linux it also checks sysfs for a pointer to the active console.
30//config: If cttyhack is able to find the real console device, it closes 30//config: If cttyhack is able to find the real console device, it closes
31//config: stdin/out/err and reopens that device. 31//config: stdin/out/err and reopens that device.
32//config: Then it executes the given program. Opening the device will make 32//config: Then it executes the given program. Opening the device will make
33//config: that device a controlling tty. This may require cttyhack 33//config: that device a controlling tty. This may require cttyhack
34//config: to be a session leader. 34//config: to be a session leader.
35//config: 35//config:
36//config: Example for /etc/inittab (for busybox init): 36//config: Example for /etc/inittab (for busybox init):
37//config: 37//config:
38//config: ::respawn:/bin/cttyhack /bin/sh 38//config: ::respawn:/bin/cttyhack /bin/sh
39//config: 39//config:
40//config: Starting an interactive shell from boot shell script: 40//config: Starting an interactive shell from boot shell script:
41//config: 41//config:
42//config: setsid cttyhack sh 42//config: setsid cttyhack sh
43//config: 43//config:
44//config: Giving controlling tty to shell running with PID 1: 44//config: Giving controlling tty to shell running with PID 1:
45//config: 45//config:
46//config: # exec cttyhack sh 46//config: # exec cttyhack sh
47//config: 47//config:
48//config: Without cttyhack, you need to know exact tty name, 48//config: Without cttyhack, you need to know exact tty name,
49//config: and do something like this: 49//config: and do something like this:
50//config: 50//config:
51//config: # exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1' 51//config: # exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
52//config: 52//config:
53//config: Starting getty on a controlling tty from a shell script: 53//config: Starting getty on a controlling tty from a shell script:
54//config: 54//config:
55//config: # getty 115200 $(cttyhack) 55//config: # getty 115200 $(cttyhack)
56 56
57//usage:#define cttyhack_trivial_usage 57//usage:#define cttyhack_trivial_usage
58//usage: "[PROG ARGS]" 58//usage: "[PROG ARGS]"