diff options
| author | Miguel <m.i@gmx.at> | 2018-10-17 22:52:28 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-10-17 22:52:28 +0200 |
| commit | 4d1a149531bc5d672cdf4a5a3e010662f9611d61 (patch) | |
| tree | a9bac45399bc2b09d927914c4bd34ff1338ea3b1 /userspace/init.c | |
| parent | 474c803c32fe055b4f09cb779f22b70d7eba8325 (diff) | |
starting rewriting scheduling ...v0.2
Diffstat (limited to 'userspace/init.c')
| -rw-r--r-- | userspace/init.c | 112 |
1 files changed, 26 insertions, 86 deletions
diff --git a/userspace/init.c b/userspace/init.c index e1ab531..dc21678 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -1,98 +1,38 @@ -//char *argv1[]={"xterm","/bin/foolstart",0}; -char *argv1[]={"xterm","/bin/fsh",0}; -//char *argv1[]={"xterm","/bin/vim",0}; -//char *argv1[]={"xterm","/bin/nc",0}; +/** xinit + * + * TODO: console version + * + * */ + char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; -int main(int argc, char **argv) -{ - execve("/bin/xterm",argv1,env1); - /* +#define LAUNCH_COUNT 3 - int pid=fork(); +char *argv1[][4]={ + {"/bin/xterm","xterm","/bin/fsh",0}, + {"/bin/xterm","xterm","/bin/fsh",0}, + {"/bin/xterm","xterm","/bin/fsh",0}, +}; - if(!pid) - { - execve("/bin/xterm",argv1,env1); - } - else - { - while(1) - { - _gui_win(); - vesa_init(0); - void *tty=terminal_init_vesa(); - getchar(); - terminal_put('X'); - } +void fork_and_exec(char **argv) +{ + int pid=fork(); - } - */ + if(!pid) //child + { + execve(argv[0],&argv[1],env1); + while(1);//hopefully never reached + } } - /* - 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}; - +int main(int argc, char **argv) +{ - // loop forever and spawn shells if the top-shell exits - while(1) + for(int i=0;i<LAUNCH_COUNT;i++) { + fork_and_exec(argv1[i]); + } - 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"); - - } + wait(999);/// TODO: here we should wait for commnads to spawn new processes? - return 0; } - */ |
