Daniel writes:
I've found a problem with job control when the init process is restarted. If the system boots for the first time, I get job control on a serial terminal - no problems. However, when I restart init by issuing "init -q", then the shell no longer has job control. I traced this a problem in console_init in the file init.c. What was happening after the restart is that the first compare if (ioctl(0, TIOCGSERIAL, &sr) == 0) { ... } else if (ioctl(0, VT_GETSTATE, &vt) == 0) { ... } else { ... // assume /dev/console } returned error and subsequently the code assumes /dev/console as the console, which does not support job control. Checking the errno after the first call showed that the system was complaining about the file descriptor. This is probably because the previous init process had closed all its file descriptors which the new init process had inherited.
This commit is contained in:
parent
40ea66cd9d
commit
3c8064ff69
18
init/init.c
18
init/init.c
@ -661,7 +661,7 @@ static void init_reboot(unsigned long magic)
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
/* We have to fork here, since the kernel calls do_exit(0) in
|
/* We have to fork here, since the kernel calls do_exit(0) in
|
||||||
* linux/kernel/sys.c, which can cause the machint to panic when
|
* linux/kernel/sys.c, which can cause the machine to panic when
|
||||||
* the init process is killed.... */
|
* the init process is killed.... */
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__)
|
#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__)
|
||||||
@ -738,6 +738,22 @@ static void exec_signal(int sig)
|
|||||||
sigaddset(&unblock_signals, SIGTSTP);
|
sigaddset(&unblock_signals, SIGTSTP);
|
||||||
sigprocmask(SIG_UNBLOCK, &unblock_signals, NULL);
|
sigprocmask(SIG_UNBLOCK, &unblock_signals, NULL);
|
||||||
|
|
||||||
|
/* Open the new terminal device */
|
||||||
|
if ((device_open(a->terminal, O_RDWR)) < 0) {
|
||||||
|
if (stat(a->terminal, &sb) != 0) {
|
||||||
|
message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal);
|
||||||
|
} else {
|
||||||
|
message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal);
|
||||||
|
}
|
||||||
|
halt_signal(SIGUSR1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure the terminal will act fairly normal for us */
|
||||||
|
set_term(0);
|
||||||
|
/* Setup stdout, stderr on the supplied terminal */
|
||||||
|
dup(0);
|
||||||
|
dup(0);
|
||||||
|
|
||||||
messageD(CONSOLE | LOG, "Trying to re-exec %s", a->command);
|
messageD(CONSOLE | LOG, "Trying to re-exec %s", a->command);
|
||||||
execl(a->command, a->command, NULL);
|
execl(a->command, a->command, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user