Exemplo n.º 1
0
/*
 * The mother of all processes.
 */
int
main(int argc __unused, char **argv)
{
	/* Dispose of random users. */
	if (getuid() != 0)
		errx(1, "%s", strerror(EPERM));

	runcom(argv);
	return 1;
}
Exemplo n.º 2
0
/*
 * The mother of all processes.
 */
int
main(int argc __unused, char **argv)
{
	/* Dispose of random users. */
	if (getuid() != 0)
		errx(1, "%s", strerror(EPERM));

	/* Init is not allowed to die, it would make the kernel panic */
	signal(SIGTERM, SIG_IGN);

	runcom(argv);
	return 1;
}
Exemplo n.º 3
0
int
run_multi()
{
    int i,j;
    pid_t pid;
    int found;

    /* Run /etc/rc if not in single user */
#ifndef OINIT_RC
    if(prevtrans==SINGLE) runcom();
#else
    if(prevtrans==SINGLE) runcom(OINIT_RC);
#endif
    if(transition!=MULTI) return(-1);

    syslog(LOG_EMERG,"*** Starting multi-user mode ***");

    /* Fork shell interface for each console */
    for(i=0; i<ncons; i++) {
        if(ttys[i].pid==0) {
            switch(pid=fork()) {
            case 0:
                start_session(i,0,NULL);
                break;
            case -1:
                printf("%s: %s\n",progname,strerror(errno));
                break;
            default:
                ttys[i].pid=pid;
                break;
            }
        }
    }
    /* Initialize any other services we'll use - most probably this will
     * be a 'telnet' service (some day...).
     */
    /* */

    /* Emulate multi-user */
    while(transition==MULTI) {
        /* XXX Modify this to allow for checking for the input on
         * XXX listening sockets, and forking a 'telnet' service.
         */
        /* */

        /* Wait for any process to exit */
        pid=waitpid(-1,(int *)0,0);
        if(pid==-1) continue;
        found=0;
        j=-1;
        /* search if it's one of our sessions */
        for(i=0; i<ncons; i++) {
            if(ttys[i].pid==pid) {
                found++;
                j=i;
                ttys[j].pid=0;
                break;
            }
        }
        if(!found) {
            /* Just collect the process's status */
            continue;
        } else {
            /* restart shell() on a console, if it died */
            if(transition!=MULTI) return(0);
            switch(pid=fork()) {
            case 0:
                sleep(1);
                start_session(j,0,NULL);
                break;
            case -1:
                printf("%s: %s\n",progname,strerror(errno));
                break;
            default:
                ttys[j].pid=pid;
                break;
            }
        }
    }
}