You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
554 B

#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);
}
}