summaryrefslogtreecommitdiff
path: root/userspace/init.c
blob: 645acd9e2237601707900d3cae46eee944711dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <stdio.h>
#include <time.h>
#include "put_pixel.h"
#include "newcalls.h"


int main(int argc, char **argv)
{

    // loop forever and spawn shells if the top-shell exits
    int fds[2];
    _pipe(fds);


	int pid=_fork();

	if(pid==0)
	{
            _execve("/bin/xterm",NULL,NULL); 
	    int pid=_fork();

            if(pid==0)
            {
                _execve("/bin/xterm",NULL,NULL); 
            }
            else
            {
                _execve("/bin/xterm",NULL,NULL); 
            }
	}
        else
        {
            _execve("/bin/xterm",NULL,NULL); 
            while(1); // block

	    int pid=_fork();
            if(pid==0)
            {
                _execve("/bin/pain2",NULL,NULL); 
            }
            else
            {
                _execve("/bin/pain1",NULL,NULL); 
                //_execve("/bin/pain3",NULL,NULL); 
            }
        }


        return 0;
    //

    char *argv1[]={"/bin/fsh",0};
    char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0};


    // loop forever and spawn shells if the top-shell exits
    while(1)
    {

	int pid=_fork();

	if(pid==0)
	{
	    printf("fool-init: spawning fool-shell\n");
	    _execve("/bin/fsh",argv1,env1); // replace process with our foolshell :)
	    while(1) puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!\n");
	}

	// wait until our child process state changes (exits)
	// and respawn SHELL 
	_wait(pid);
	
	printf("fool-init: respawning new fool-shell\n");

    } 

    return 0;
}