49 lines
980 B
C++
49 lines
980 B
C++
// vim: set noet ts=4 sw=4:
|
|
|
|
#include "../libsys/stub.h"
|
|
#include "../libsys/string.h"
|
|
|
|
//#include "../libsys/string.h"
|
|
|
|
extern "C" void main() {
|
|
char cmd_buff[100];
|
|
uint8_t bufferpos = 0;
|
|
|
|
uint8_t id = sys_getpid();
|
|
uint8_t x = 0;
|
|
|
|
char text[] = "kappl";
|
|
write(1, text, sizeof(text), 0, (int)id);
|
|
|
|
while(1){
|
|
char msg[11];
|
|
int len;
|
|
len = read(0, msg, 1);
|
|
if(len){
|
|
write(0, msg, len, 6+x, id);
|
|
memcpy(&cmd_buff[bufferpos], msg, len);
|
|
bufferpos+=len;
|
|
for(uint8_t i=0; i<len; i++)
|
|
if(msg[i] == '\n'){
|
|
x=0;
|
|
write(0, " ", 52, 6+x, id);
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
x++;
|
|
}
|
|
}
|
|
}
|