sbin/init/init.c
/*
 * Bring the system down to single user.
 */
Bring the system down to single user.
Bring the system down to single user .
state_func_t
death()
{
	register session_t *sp;
	register int i;
	pid_t pid;
	static const int death_sigs[3] = { SIGHUP, SIGTERM, SIGKILL };
	for (sp = sessions; sp; sp = sp->se_next)
		sp->se_flags |= SE_SHUTDOWN;
	logwtmp("~", "shutdown", "");
	for (i = 0; i < 3; ++i) {
		if (kill(-1, death_sigs[i]) == -1 && errno == ESRCH)
			return (state_func_t) single_user;
		clang = 0;
		alarm(DEATH_WATCH);
		do
			if ((pid = waitpid(-1, (int *)0, 0)) != -1)
				collect_child(pid);
		while (clang == 0 && errno != ECHILD);
		if (errno == ECHILD)
			return (state_func_t) single_user;
	}
	warning("some processes would not die; ps axl advised");
	return (state_func_t) single_user;
}
state_func_t death ( ) { register session_t * sp ; register int i ; pid_t pid ; static const int death_sigs [ 3 ] = { SIGHUP , SIGTERM , SIGKILL } ; for ( sp = sessions ; sp ; sp = sp -> se_next ) sp -> se_flags |= SE_SHUTDOWN ; logwtmp ( " " , " " , " " ) ; for ( i = 0 ; i < 3 ; ++ i ) { if ( kill ( -1 , death_sigs [ i ] ) == -1 && errno == ESRCH ) return ( state_func_t ) single_user ; clang = 0 ; alarm ( DEATH_WATCH ) ; do if ( ( pid = waitpid ( -1 , ( int * ) 0 , 0 ) ) != -1 ) collect_child ( pid ) ; while ( clang == 0 && errno != ECHILD ) ; if ( errno == ECHILD ) return ( state_func_t ) single_user ; } warning ( " " ) ; return ( state_func_t ) single_user ; }
Bring the system down to single user.
Bring the system down to single user .
/* NB: should send a message to the session logger to avoid blocking. */