优化退出流程,统一注册到on_exit(
This commit is contained in:
@ -239,6 +239,7 @@ int teml(Ctl *self,int fifo[2])
|
||||
//创建线程用于定期清理日志
|
||||
pthread_create(&self->logwathcher,NULL,self->logmanager->clear_log,self->logmanager);
|
||||
command->statue = 0;
|
||||
self->command = command;
|
||||
do
|
||||
{ //设置缓冲区,接收用户输入
|
||||
write(STDOUT_FILENO,PROMPT,sizeof(PROMPT));
|
||||
@ -252,11 +253,14 @@ int teml(Ctl *self,int fifo[2])
|
||||
const char fexp[256] = {'\0'};
|
||||
memcpy(&input,&fexp,MAX_BUF);
|
||||
}while(command->statue == 0);
|
||||
pthread_kill(self->logwathcher,SIGUSR1);
|
||||
log_manager_stop(self->logmanager);
|
||||
pthread_join(self->logwathcher,NULL);
|
||||
//关闭log定期清理程序
|
||||
close(fifo[0]);
|
||||
|
||||
close(fifo[1]);
|
||||
free_history(self);
|
||||
self->command = NULL;
|
||||
free(command);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user