Compare commits

..

No commits in common. "a815beacfb5d399d0a97bdbc3b2027cb919b2b0c" and "7e9744419ed6013e60fe7b34181f0258f65c5f62" have entirely different histories.

3 changed files with 3 additions and 43 deletions

View File

@ -67,14 +67,11 @@ int main()
return 1;
}
pid_t result;
for (;;)
{
while ((result = wait(NULL)) == 0) // No child has exited yet
while (wait(NULL) == 0) // No child has exited yet
{
msleep(100);
}
if (result == child) { return 0; }
}
}

View File

@ -1,7 +1,6 @@
#include <luna.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
@ -10,8 +9,8 @@ static int status;
typedef struct
{
char* buffer;
size_t size;
size_t capacity;
long size;
long capacity;
} command;
void show_prompt()
@ -19,33 +18,6 @@ void show_prompt()
printf("[%ld]> ", getpid());
}
int command_matches(command* cmd, const char* string)
{
if (cmd->size <= strlen(string)) // cmd->size includes null terminator
return 0;
return strncmp(cmd->buffer, string, strlen(string)) == 0;
}
int command_matches_exactly(command* cmd, const char* string)
{
if (cmd->size <= strlen(string)) // cmd->size includes null terminator
return 0;
if (cmd->size > (strlen(string) + 1)) return 0;
return strncmp(cmd->buffer, string, strlen(string)) == 0;
}
int command_match_builtins(command* cmd)
{
if (command_matches(cmd, "exit ")) { exit(atoi(cmd->buffer + 5)); }
if (command_matches_exactly(cmd, "exit")) { exit(0); }
if (command_matches_exactly(cmd, "pid"))
{
printf("pid %ld, ppid %ld\n", getpid(), getppid());
return 1;
}
return 0;
}
void command_expand(command* cmd, long new_capacity)
{
char* buffer = realloc(cmd->buffer, new_capacity);
@ -86,12 +58,6 @@ void command_clear(command* cmd)
void command_execute(command* cmd)
{
command_push(cmd, '\0');
if (command_match_builtins(cmd))
{
command_clear(cmd);
show_prompt();
return;
}
pid_t child = fork();
if (child < 0)
{

View File

@ -7,7 +7,6 @@
#include "memory/PMM.h"
#include "memory/VMM.h"
#include "misc/hang.h"
#include "misc/reboot.h"
#include "misc/utils.h"
#include "panic/Panic.h"
#include "std/assert.h"
@ -281,7 +280,6 @@ void Scheduler::task_exit(Context* context, int64_t status)
return true;
});
}
else { reboot(); }
task_yield(context);
}
@ -300,7 +298,6 @@ void Scheduler::task_misbehave(Context* context, int64_t status)
return true;
});
}
else { reboot(); }
task_yield(context);
}