Add std{in,out,err}_h

This commit is contained in:
Tony Garnock-Jones 2011-01-02 10:30:17 -05:00
parent 5e7a6efeb8
commit 1994245cea
2 changed files with 19 additions and 0 deletions

View File

@ -37,6 +37,10 @@ typedef unsigned char u_char;
/* TODO: reuse stacks (via a freelist) */
/* TODO: investigate avoiding syscall in swapcontext, setcontext etc. */
IOHandle *stdin_h = NULL;
IOHandle *stdout_h = NULL;
IOHandle *stderr_h = NULL;
static volatile int harness_running = 1;
Process *current_process = NULL;
@ -250,7 +254,12 @@ static void clean_dead_processes(void) {
}
void boot_harness(void) {
stdin_h = new_iohandle(0);
stdout_h = new_iohandle(1);
stderr_h = new_iohandle(2);
ICHECK(getcontext(&scheduler), "boot_harness getcontext");
while (1) {
while (runlist.count) {
queue_t work = runlist;
@ -268,6 +277,12 @@ void boot_harness(void) {
//info("Blocking for events\n");
event_loop(EVLOOP_ONCE);
}
info("Shutting down.\n");
delete_iohandle(stdin_h);
delete_iohandle(stdout_h);
delete_iohandle(stderr_h);
}
void interrupt_harness(void) {

View File

@ -25,6 +25,10 @@ typedef struct IOHandle {
unsigned short error_kind;
} IOHandle;
extern IOHandle *stdin_h;
extern IOHandle *stdout_h;
extern IOHandle *stderr_h;
extern Process *current_process;
extern void yield(void);