05-21-07 12:21 AM
2007-05-20, 04:55(-07), Bin Chen:
> I have an embedded board running Linux and with busybox as the shell.
> I am upgrading the busybox to a higher version, but at the first time
> I forget to compile the stty command in busybox, so the system is
> booting without stty command. This time the /dev/tty can't be open
> with error message of "can't turn on job control". The second time I
> compiled the stty in busybox then the /dev/tty can works. But by
> greping the /etc/ and /sbin/ directory, i can't find a script running
> stty, so who runs stty and then affect the busybox behavior?
stty is a command line interface to the tcsetattr functio
(which is a wrapper to some tty ioctl on Linux). Many commands
(including the shell, vi...) will call that tcsetattr function
directly, they don't need stty.
The fact that you can't open /dev/tty or that job control
doesn't work is more probably due to the fact that the shell
doesn't have a controlling terminal. stty can't do anything
about that. This may happen if you're trying to run it on
/dev/console (as when booting Linux with init=/bin/sh). Instead,
you should have a line in /etc/inittab that runs some getty
command on /dev/ttyS0 or whatever your serial interface is (for
a serial console) and remove the init=...
> Another question is, when I start a command from shell, and press CTRL
> +C, who will receive the SIGINT? Is it the shell first received the
> signal and then forward to the running process or kernel send the
> signal directly to the process? So the same for all the tty related
> signals?
[...]
The foreground process group of the terminal will get it. The
shell, at its prompt will be in that group. When you run a
command in foreground (without &), the shell will create a new
process group and make it the foreground process group of that
terminal. When you hit Ctrl-C, that process group, that is the
command and every process it spawns, will get the SIGINT.
When using &, the shell starts a new process group but doesn't
make it the foreground process group. So, it won't get the
SIGINT, but it will get a SIGTTIN for instance if any of its
processes tries to read from the terminal.
See
info -f libc -n 'Job Control'
for more details.
--
Stéphane
[ Post a follow-up to this message ]
|