summaryrefslogtreecommitdiff
path: root/userspace/xterm/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/xterm/xterm.c')
-rw-r--r--userspace/xterm/xterm.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c
index b333794..5540ac9 100644
--- a/userspace/xterm/xterm.c
+++ b/userspace/xterm/xterm.c
@@ -8,49 +8,56 @@ char *argv1[]={"xterm","/bin/fsh",0};
int main(int argc, char **argv)
{
+ // we need a window
_gui_win();
+ // basically loads font and sets a few constants
vesa_init(NULL);
+
+ // init tty and set vesa output funcs
void *tty=terminal_init_vesa();
//int xterm_in[2];
int xterm_out[2];
//_pipe(xterm_in);
- _pipe(xterm_out);
+ pipe(xterm_out);
- int pid=_fork();
+ int pid=fork();
- if(!pid)
+ if(!pid) // child
{
int tty_fd=_open("/dev/tty");
//_close(xterm_in[1]);
- _close(xterm_out[0]);
+ close(xterm_out[0]);
- _dup2(tty_fd,0);// stdin
- _dup2(xterm_out[1],1);// stdout
- _dup2(xterm_out[1],2);// stderr
+ dup2(tty_fd,0);// stdin
+ dup2(xterm_out[1],1);// stdout
+ dup2(xterm_out[1],2);// stderr
// replace process with our foolshell or whatever
if(argc==1)_execve(argv1[1],argv1,environ);
- _execve(argv[1],argv,environ);
+ execve(argv[1],argv,environ);
- while(1);
+ printf("unable to execve %s",argv[1]); // never reached
}
-
- //_close(xterm_in[0]);
- _close(xterm_out[1]);
-
- //_dup2(xterm_in[1],0); // compositor writes here.
- //_close(xterm_in[1]);
-
- while(1)
- {
- char buf[1];
-
- _read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr
- terminal_put(tty,buf[0]);
- _gui_rect();
+ else{
+
+ //_close(xterm_in[0]);
+ close(xterm_out[1]);
+
+ //_dup2(xterm_in[1],0); // compositor writes here.
+ //_close(xterm_in[1]);
+
+ // TODO quit if execve fails or child exits...
+ while(1)
+ {
+ char buf[1];
+
+ read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr
+ terminal_put(tty,buf[0]);
+ }
}
+
}