jos/user/initsh.c
Anish Athalye c67463e23c Lab 5
2018-10-24 20:44:45 -04:00

28 lines
522 B
C

#include <inc/lib.h>
void
umain(int argc, char **argv)
{
int i, r, x, want;
cprintf("initsh: running sh\n");
// being run directly from kernel, so no file descriptors open yet
close(0);
if ((r = opencons()) < 0)
panic("opencons: %e", r);
if (r != 0)
panic("first opencons used fd %d", r);
if ((r = dup(0, 1)) < 0)
panic("dup: %e", r);
while (1) {
cprintf("init: starting sh\n");
r = spawnl("/sh", "sh", (char*)0);
if (r < 0) {
cprintf("init: spawn sh: %e\n", r);
continue;
}
wait(r);
}
}