#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "fun.h"
|
|
|
|
void eval(char *cmdline);
|
|
void sigint_handler();
|
|
pid_t getpid(void);
|
|
pid_t main_proc_pid;
|
|
|
|
int main()
|
|
{
|
|
char cmdline[MAXLINE];
|
|
main_proc_pid = getpid();
|
|
signal(SIGINT, sigint_handler);
|
|
|
|
while(1)
|
|
{
|
|
printf("COMMAND->");
|
|
fflush(stdin);
|
|
fgets(cmdline, MAXLINE, stdin);
|
|
eval(cmdline);
|
|
history(cmdline);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void sigint_handler()
|
|
{
|
|
pid_t pid = getpid();
|
|
if(pid != main_proc_pid)
|
|
{
|
|
exit(0);
|
|
}
|
|
}
|