|
|
@ -1,21 +1,23 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include "fun.h" |
|
|
|
|
|
|
|
#include "fun_2.c" |
|
|
|
#include "fun_1.c"; |
|
|
|
#include "fun.h" |
|
|
|
char *getcwd(char *buf,size_t size); |
|
|
|
|
|
|
|
int main() |
|
|
|
{ |
|
|
|
char cmdline[MAXLINE]; |
|
|
|
main_proc_pid = getpid(); |
|
|
|
//signal(SIGINT, sigint_handler); |
|
|
|
|
|
|
|
char pwd[64]; |
|
|
|
|
|
|
|
signal(SIGINT, sigint_handler); |
|
|
|
while(1) |
|
|
|
{ |
|
|
|
printf("COMMAND->"); |
|
|
|
getcwd(pwd, 64); |
|
|
|
printf("[root@yueshell %s]# ",pwd); |
|
|
|
//printf("COMMAND->"); |
|
|
|
fflush(stdin); |
|
|
|
fgets(cmdline, MAXLINE, stdin); |
|
|
|
fgets(cmdline, MAXLINE, stdin); |
|
|
|
eval(cmdline); |
|
|
|
history(cmdline); |
|
|
|
} |
|
|
@ -24,9 +26,6 @@ int main() |
|
|
|
|
|
|
|
void sigint_handler() |
|
|
|
{ |
|
|
|
pid_t pid = getpid(); |
|
|
|
if(pid != main_proc_pid) |
|
|
|
{ |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
printf("\nWarning : shell exit!!\n"); |
|
|
|
exit(0); |
|
|
|
} |