BigOS/user/shell_1.c
2022-12-31 22:29:46 +08:00

54 lines
1.2 KiB
C

#include "type.h"
#include "const.h"
#include "protect.h"
#include "string.h"
#include "proc.h"
#include "global.h"
#include "proto.h"
#include "stdio.h"
int main(int arg, char *argv[])
{
if (0 == fork()) {
int stdin = open("dev_tty0", O_RDWR);
int stdout = open("dev_tty0", O_RDWR);
int stderr = open("dev_tty0", O_RDWR);
char buf[1024];
int pid;
int times = 0;
while (1)
{
printf("\nminiOS:/ $ ");
if (gets(buf) && strlen(buf) != 0)
{
if (exec(buf) != 0)
{
printf("exec failed: file not found!\n");
continue;
}
}
}
}
else {
int stdin = open("dev_tty1", O_RDWR);
int stdout = open("dev_tty1", O_RDWR);
int stderr = open("dev_tty1", O_RDWR);
char buf[1024];
int pid;
int times = 0;
while (1)
{
printf("\nminiOS:/ $ ");
if (gets(buf) && strlen(buf) != 0)
{
if (exec(buf) != 0)
{
printf("exec failed: file not found!\n");
continue;
}
}
}
}
}