Compare commits
No commits in common. "a18e50ff3434f700e56c93a0414420d68584834c" and "b6fb5f3dfe5b682112f916366ee71b4c378bb04d" have entirely different histories.
a18e50ff34
...
b6fb5f3dfe
@ -7,6 +7,4 @@ function(luna_app SOURCE_FILE APP_NAME)
|
||||
endfunction()
|
||||
|
||||
luna_app(init.c init)
|
||||
luna_app(cat.c cat)
|
||||
luna_app(edit.c edit)
|
||||
luna_app(sh.c sh)
|
||||
|
41
apps/cat.c
41
apps/cat.c
@ -1,41 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void do_cat(FILE* f)
|
||||
{
|
||||
char buffer[4096];
|
||||
|
||||
while (1)
|
||||
{
|
||||
size_t nread = fread(buffer, 1, sizeof(buffer), f);
|
||||
if (nread == 0) return;
|
||||
fwrite(buffer, 1, nread, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FILE* f;
|
||||
|
||||
if (argc < 2) { do_cat(stdin); }
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "-")) f = stdin;
|
||||
else
|
||||
{
|
||||
f = fopen(argv[i], "r");
|
||||
if (!f)
|
||||
{
|
||||
perror(argv[i]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
do_cat(f);
|
||||
if (f != stdin) fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
35
apps/edit.c
35
apps/edit.c
@ -1,35 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FILE* f;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [file]", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
f = fopen(argv[1], "w");
|
||||
if (!f)
|
||||
{
|
||||
perror(argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buffer[4096];
|
||||
|
||||
while (1)
|
||||
{
|
||||
char* rc = fgets(buffer, sizeof(buffer), stdin);
|
||||
if (rc == 0) break;
|
||||
if (!strcmp(rc, "EOF\n")) break;
|
||||
fputs(buffer, f);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
@ -90,7 +90,6 @@ int main()
|
||||
if (child == 0)
|
||||
{
|
||||
char** argv = split_command_into_argv(command);
|
||||
if (argv[0] == NULL) return 0;
|
||||
sh_execvp(argv);
|
||||
perror(argv[0]);
|
||||
return 1;
|
||||
|
@ -71,10 +71,7 @@ void decode_page_fault_error_code(u64 code)
|
||||
{
|
||||
// FIXME: Kill this process with SIGSEGV once we have signals and all that.
|
||||
kerrorln("Current task %zu was terminated because of a page fault", Scheduler::current()->id);
|
||||
Scheduler::current()->state = ThreadState::Exited;
|
||||
Scheduler::current()->status = 127;
|
||||
kernel_yield();
|
||||
unreachable();
|
||||
kernel_exit();
|
||||
}
|
||||
|
||||
CPU::print_stack_trace_at(regs);
|
||||
|
Loading…
Reference in New Issue
Block a user