Files
RockOS/programs/vga_text_term/main.c

44 lines
610 B
C

#include <unistd.h>
void term();
int ptys;
int ptym;
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
ptym = pty(&ptys);
if (fork() == 0) {
close(ptym);
dup2(ptys, 0);
dup2(0, 1);
dup2(0, 2);
exec("/rocksh.elf");
}
close(ptys);
dup2(ptym, 0);
dup2(0, 1);
dup2(0, 2);
term();
return 0;
}
void term() {
int vga_fd = open("/dev/tvga");
if (vga_fd == -1) return;
while (1) {
char c;
int rd = read(0, &c, 1);
if (rd > 0) {
write(vga_fd, &c, 1);
}
}
}