From c059e7479e680a3b2061818cd7c2bc34871e9359 Mon Sep 17 00:00:00 2001 From: guo_peixu Date: Fri, 24 Jun 2022 16:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=97=A5=E6=9C=9F=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=E6=97=A0=E6=95=88=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shm_consumer/MESA_shm_consumer.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/shm_consumer/MESA_shm_consumer.c b/shm_consumer/MESA_shm_consumer.c index c574cf2..373e98f 100644 --- a/shm_consumer/MESA_shm_consumer.c +++ b/shm_consumer/MESA_shm_consumer.c @@ -154,7 +154,7 @@ struct log_file_list * create_log_file_node(char *log_file) curtime = time(NULL); localtime_r(&curtime, &date); n = snprintf(node->real_log_file, sizeof(node->real_log_file), "%s.%d-%d-%d", - node->log_file_pre, date.tm_year + 1900, date.tm_mon, date.tm_mday); + node->log_file_pre, date.tm_year + 1900, date.tm_mon + 1, date.tm_mday); if(n >= sizeof(node->real_log_file)){ goto error; } @@ -221,7 +221,7 @@ int check_reopen_log_file(struct log_file_list *node) node->create_date = date; n = snprintf(node->real_log_file, sizeof(node->real_log_file), "%s.%d-%d-%d", node->log_file_pre, - node->create_date.tm_year, node->create_date.tm_mon, node->create_date.tm_mday); + node->create_date.tm_year + 1900, node->create_date.tm_mon + 1, node->create_date.tm_mday); if(n >= sizeof(node->real_log_file)){ return CONSUMER_ERROR; } @@ -314,18 +314,6 @@ int producer_pid_is_cared(int producer_pid) } return 0; } - -int check_care_pid_repeat(int pid) -{ - struct care_pid_list *tmp; - struct care_pid_list *n; - list_for_each_entry_safe(tmp, n, &g_care_pid_list.list, list){ - if(tmp->pid == pid){ - return CONSUMER_ERROR; - } - } - return CONSUMER_SUCCESS; -} struct care_pid_list *create_care_pid_node(int pid) { struct care_pid_list *node; @@ -339,7 +327,7 @@ struct care_pid_list *create_care_pid_node(int pid) } int add_care_pid_node(struct care_pid_list *node, int pid) { - if(check_care_pid_repeat(pid) == CONSUMER_SUCCESS){ + if(!producer_pid_is_cared(pid)){ list_add(&node->list, &g_care_pid_list.list); }else{ free(node); @@ -490,11 +478,9 @@ int get_cur_tty_fd() { FILE *fp = NULL; char cur_tty_name[DEFAUT_BUF_SIZE] = {0}; - char command[DEFAUT_BUF_SIZE] = {0}; char *p = NULL; int cur_tty_fd = -1; - snprintf(command, sizeof(command), "tty"); - fp = popen(command, "r"); + fp = popen("tty", "r"); if(fp == NULL){ return -1; }