summaryrefslogtreecommitdiff
path: root/userspace/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/init.c')
-rw-r--r--userspace/init.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/userspace/init.c b/userspace/init.c
index e432ef9..0fb23d2 100644
--- a/userspace/init.c
+++ b/userspace/init.c
@@ -1,46 +1,35 @@
-/** xinit
- *
- * TODO: console version
- *
- * */
-
-#define LAUNCH_COUNT 0
-static char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0};
+ /*
+ * @file
+ *
+ * This is the FoolOS Init process running on pid=1.
+ *
+ * I just spawns a `fool-term` each time an character arrives
+ * on its '/dev/tty' (controlling terminal of this process)
+ *
+ */
+
+static char *env1[]={"HOME=/home/miguel","PS1=$","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0};
static char *argv1[]={"xterm","/bin/fsh",0};
-/*
-
-char *argv1[][4]={
- {"/bin/xterm","xterm","/bin/fsh",0},
- {"/bin/xterm","xterm","/bin/fsh",0},
- {"/bin/xterm","xterm","/bin/fsh",0},
-};
-*/
-
void fork_and_exec()
{
int pid=fork();
- if(!pid) //child
+
+ if(!pid)
{
+ // execve in child
execve("/bin/xterm",argv1,env1);
}
}
int main(int argc, char **argv)
{
- int pid=fork();
-
- for(int i=0;i<LAUNCH_COUNT;i++)
- {
- fork_and_exec();
- }
-
int tty_fd=_open("/dev/tty");
while(1)
{
char buf[1];
- read(tty_fd,buf,1); //
+ read(tty_fd,buf,1);
fork_and_exec();
}
}