aboutsummaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/init.c b/init.c
index f6e9eff97..ce2f237c7 100644
--- a/init.c
+++ b/init.c
@@ -130,32 +130,40 @@ void message(int device, char *fmt, ...)
130void set_term( int fd) 130void set_term( int fd)
131{ 131{
132 struct termios tty; 132 struct termios tty;
133#if 0
133 static const char control_characters[] = { 134 static const char control_characters[] = {
134 '\003', '\034', '\177', '\030', '\004', '\0', 135 '\003', '\034', '\177', '\030', '\004', '\0',
135 '\1', '\0', '\021', '\023', '\032', '\0', '\022', 136 '\1', '\0', '\021', '\023', '\032', '\0', '\022',
136 '\017', '\027', '\026', '\0' 137 '\017', '\027', '\026', '\0'
137 }; 138 };
139#else
140 static const char control_characters[] = {
141 '\003', '\034', '\177', '\025', '\004', '\0',
142 '\1', '\0', '\021', '\023', '\032', '\0', '\022',
143 '\017', '\027', '\026', '\0'
144 };
145#endif
138 146
139 tcgetattr(fd, &tty); 147 tcgetattr(fd, &tty);
140 148
141 /* Make it be sane */ 149 /* set control chars */
142 tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; 150 memcpy(tty.c_cc, control_characters, sizeof(control_characters));
143 tty.c_cflag |= HUPCL|CLOCAL;
144
145 /* input modes */
146 tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY;
147 151
148 /* use line dicipline 0 */ 152 /* use line dicipline 0 */
149 tty.c_line = 0; 153 tty.c_line = 0;
150 154
155 /* Make it be sane */
156 //tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
157 //tty.c_cflag |= HUPCL|CLOCAL;
158
159 /* input modes */
160 tty.c_iflag = ICRNL|IXON|IXOFF;
161
151 /* output modes */ 162 /* output modes */
152 tty.c_oflag = OPOST|ONLCR; 163 tty.c_oflag = OPOST|ONLCR;
153 164
154 /* local modes */ 165 /* local modes */
155 tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; 166 tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN;
156
157 /* control chars */
158 memcpy(tty.c_cc, control_characters, sizeof(control_characters));
159 167
160 tcsetattr(fd, TCSANOW, &tty); 168 tcsetattr(fd, TCSANOW, &tty);
161} 169}
@@ -210,7 +218,7 @@ static void console_init()
210 218
211 console = the_console; 219 console = the_console;
212 /* 2.2 kernels: identify the real console backend and try to use it */ 220 /* 2.2 kernels: identify the real console backend and try to use it */
213 if (ioctl(0,TIOCGSERIAL,&sr) == 0) { 221 if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
214 /* this is a serial console */ 222 /* this is a serial console */
215 snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); 223 snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
216 } 224 }
@@ -245,6 +253,7 @@ static void console_init()
245 /* check for serial console and disable logging to tty3 & running a 253 /* check for serial console and disable logging to tty3 & running a
246 * shell to tty2 */ 254 * shell to tty2 */
247 if (ioctl(0,TIOCGSERIAL,&sr) == 0) { 255 if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
256 message(LOG|CONSOLE, "serial console detected. Disabling 2nd virtual terminal.\r\n", console );
248 log = NULL; 257 log = NULL;
249 second_console = NULL; 258 second_console = NULL;
250 } 259 }
@@ -362,7 +371,7 @@ static void shutdown_system(void)
362 /* Allow Ctrl-Alt-Del to reboot system. */ 371 /* Allow Ctrl-Alt-Del to reboot system. */
363 reboot(RB_ENABLE_CAD); 372 reboot(RB_ENABLE_CAD);
364#endif 373#endif
365 message(CONSOLE, "The system is going down NOW !!\r\n"); 374 message(CONSOLE, "\r\nThe system is going down NOW !!\r\n");
366 sync(); 375 sync();
367 /* Send signals to every process _except_ pid 1 */ 376 /* Send signals to every process _except_ pid 1 */
368 message(CONSOLE, "Sending SIGHUP to all processes.\r\n"); 377 message(CONSOLE, "Sending SIGHUP to all processes.\r\n");
@@ -376,7 +385,9 @@ static void shutdown_system(void)
376 kill(-1, SIGKILL); 385 kill(-1, SIGKILL);
377#endif 386#endif
378 sleep(1); 387 sleep(1);
388 message(CONSOLE, "Disabling swap.\r\n");
379 waitfor(run( swap_off_cmd, console, FALSE)); 389 waitfor(run( swap_off_cmd, console, FALSE));
390 message(CONSOLE, "Unmounting filesystems.\r\n");
380 waitfor(run( umount_cmd, console, FALSE)); 391 waitfor(run( umount_cmd, console, FALSE));
381 sync(); 392 sync();
382 if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { 393 if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {