thread.c

来自「接收端的程序」· C语言 代码 · 共 63 行

C
63
字号
#include	<stdio.h>
#include	<stdlib.h>
#include	<string.h>
#include	<pthread.h>
#include	<signal.h>
#include	<mysql.h>

#include 	"devicelog.h"
#include	"queue.h"
#include	"server.h"
#include	"db.h"
#include	"logging.h"
#include	"thread.h"

LinkQueue *Q=NULL;

extern MYSQL* conn;

void exit_service()
{

	if(conn != NULL)
		disconnect(conn);
	DestroyQueue(Q);	
	
	log_info("ITWORKS","The system have exited!");
	uninit_logging();

	exit(0);
}



int main(int argc,char *argv[])
{
	
//	init_daemon();	
	
	printf("Hello!\n");
	
	init_logging();
	
	log_info("ITWORKS","The system started!");
	Q=(LinkQueue*)malloc(sizeof(LinkQueue));
	if(NULL==Q)
	{
		log_fatal("Queue","The Queue can not be malloced !\n");
		return 1;
	}

	InitQueue(Q);
	
	signal(SIGTERM,(void *)exit_service);
	signal(SIGINT, (void *)exit_service);	

	start_db_service();
	
	startserver();
		

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?