42 lines
884 B
C++
42 lines
884 B
C++
// vim: set noet ts=4 sw=4:
|
|
|
|
#include "./kappl.h"
|
|
#include "../../syscall/stub.h"
|
|
#include "../../utils/string.h"
|
|
|
|
#include "../../device/textstream.h"
|
|
extern TextStream kout;
|
|
#include "../../interrupt/guard.h"
|
|
extern Semaphore koutsem;
|
|
|
|
void KeyboardApplication::action() { // NOLINT
|
|
char cmd_buff[100];
|
|
uint8_t bufferpos = 0;
|
|
while(1){
|
|
char msg[11];
|
|
int len;
|
|
len = read(0, msg, 1);
|
|
if(len){
|
|
write(0, msg, len);
|
|
memcpy(&cmd_buff[bufferpos], msg, len);
|
|
bufferpos+=len;
|
|
for(uint8_t i=0; i<len; i++)
|
|
if(msg[i] == '\n'){
|
|
bufferpos = 0;
|
|
if(strncmp(cmd_buff, "kill ", 5) == 0){
|
|
int pid = cmd_buff[5]-0x30;
|
|
char r[] = "killing X\n";
|
|
r[8] = pid+0x30;
|
|
write(0, r, 9);
|
|
sys_kill(pid);
|
|
}
|
|
if(strncmp(cmd_buff, "killall", 7) == 0){
|
|
for(uint8_t i = 0; i<10; i++){
|
|
sys_kill(i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|