/[baselayout]/trunk/src/rc.c
Gentoo

Diff of /trunk/src/rc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2638 Revision 2640
318 318
319static char read_key (bool block) 319static char read_key (bool block)
320{ 320{
321 struct termios termios; 321 struct termios termios;
322 char c = 0; 322 char c = 0;
323 323
324 /* This locks up rc for some reason!
325 * Why? it used to work fine... */
326 return 0;
327
328 if (! isatty (STDIN_FILENO)) 324 if (! isatty (STDIN_FILENO))
329 return (false); 325 return (false);
330 326
331 /* Now save our terminal settings. We need to restore them at exit as we 327 /* Now save our terminal settings. We need to restore them at exit as we
332 will be changing it for non-blocking reads for Interactive */ 328 will be changing it for non-blocking reads for Interactive */
454 450
455static void handle_signal (int sig) 451static void handle_signal (int sig)
456{ 452{
457 int serrno = errno; 453 int serrno = errno;
458 char signame[10] = { '\0' }; 454 char signame[10] = { '\0' };
455 char *run;
456 char *prev;
459 457
460 switch (sig) { 458 switch (sig) {
461 case SIGINT: 459 case SIGINT:
462 if (! signame[0]) 460 if (! signame[0])
463 snprintf (signame, sizeof (signame), "SIGINT"); 461 snprintf (signame, sizeof (signame), "SIGINT");
472 eerror ("rc: Aborting!"); 470 eerror ("rc: Aborting!");
473 /* Kill any running services we have started */ 471 /* Kill any running services we have started */
474 signal (SIGTERM, SIG_IGN); 472 signal (SIGTERM, SIG_IGN);
475 killpg (getpgrp (), SIGTERM); 473 killpg (getpgrp (), SIGTERM);
476 474
477 /* If we're in boot runlevel then change into single-user mode */ 475 /* Notify plugins we are aborting */
478 if (strcmp (rc_get_runlevel (), RC_LEVEL_BOOT) == 0) 476 rc_plugin_run (rc_hook_abort, "rc");
477
478 run = getenv ("RUNLEVEL");
479 prev = getenv ("PREVLEVEL");
480 /* Only drop into single user mode if we're booting */
481 if ((prev && strcmp (prev, "S") == 0) ||
482 (run && strcmp (run, "S") == 0))
479 single_user (); 483 single_user ();
480 484
481 exit (EXIT_FAILURE); 485 exit (EXIT_FAILURE);
482 break; 486 break;
483 487
554 if (geteuid () != 0) 558 if (geteuid () != 0)
555 eerrorx ("%s: root access required", applet); 559 eerrorx ("%s: root access required", applet);
556 560
557 atexit (cleanup); 561 atexit (cleanup);
558 newlevel = argv[0]; 562 newlevel = argv[0];
559
560 /* Start a new process group */
561 setpgrp();
562 563
563 /* Setup a signal handler */ 564 /* Setup a signal handler */
564 signal (SIGINT, handle_signal); 565 signal (SIGINT, handle_signal);
565 signal (SIGQUIT, handle_signal); 566 signal (SIGQUIT, handle_signal);
566 signal (SIGTERM, handle_signal); 567 signal (SIGTERM, handle_signal);

Legend:
Removed from v.2638  
changed lines
  Added in v.2640

  ViewVC Help
Powered by ViewVC 1.1.20