优化退出流程,统一注册到on_exit(

This commit is contained in:
2025-09-29 16:07:11 +08:00
parent afe70e6d17
commit 8c52e4ba84
9 changed files with 163 additions and 41 deletions

View File

@ -1,6 +1,8 @@
#define _GNU_SOURCE
#include "tem/ctl.h"
#include "network/network.h"
#include "tools/toml/toml.h"
#include "tools/quit/quit.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@ -45,23 +47,15 @@ int main()
pthread_t network_id;
pthread_create(&network_id,NULL,networkmanager->run_network,(void*)networkmanager);
//启动网络监听与线程池,并加载插件
alres *resource = (alres*)malloc(sizeof(alres));
resource->loger = logsmanager;
resource->network = networkmanager;
resource->tem = teml;
on_exit(quit_all,resource);
//注册清理函数
teml->run(teml,fifo);
//启动终端
pthread_join(network_id,NULL);
//等待网络管理器进程结束
logs *log = logsmanager->log;
while(log != NULL)
{
logs *buf = log;
if(log->next !=NULL)
log = log->next;
free(buf);
}
//释放日志内存
free(teml);
free(networkmanager);
free(logsmanager);
//释放内存
return 1;
}