From a4216e907b3e139589b5fcee35874b670f985b89 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 21 Aug 2024 10:57:47 +0800
Subject: [PATCH] Add .ini parser example code
---
booster/util_proc.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/booster/util_proc.c b/booster/util_proc.c
index a17ea29..dfdabae 100644
--- a/booster/util_proc.c
+++ b/booster/util_proc.c
@@ -13,12 +13,14 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <libgen.h>
+#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
+#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
#include "util_proc.h"
#include "logger.h"
@@ -64,7 +66,7 @@
{
struct sigaction sigact, sigign;
- log_nrml("Install default signal handler.\n");
+ log_info("Install default signal handler.\n");
/* Initialize the catch signal structure. */
sigemptyset(&sigact.sa_mask);
@@ -159,7 +161,7 @@
if( check_daemon_running(pidfile) )
{
- log_err("Program already running, process exit now");
+ log_error("Program already running, process exit now");
return -1;
}
@@ -167,7 +169,7 @@
{
if( set_daemon_running(pidfile) < 0 )
{
- log_err("set program running as daemon failure\n");
+ log_error("set program running as daemon failure\n");
return -2;
}
}
@@ -175,7 +177,7 @@
{
if( record_daemon_pid(pidfile) < 0 )
{
- log_err("record program running PID failure\n");
+ log_error("record program running PID failure\n");
return -3;
}
}
@@ -209,7 +211,7 @@
{
if (mkdir(ipc_dir, mode) < 0)
{
- log_err("cannot create %s: %s\n", ipc_dir, strerror(errno));
+ log_error("cannot create %s: %s\n", ipc_dir, strerror(errno));
return -1;
}
@@ -225,11 +227,11 @@
write(fd, pid, strlen(pid));
close(fd);
- log_dbg("Record PID<%u> to file %s.\n", getpid(), pid_file);
+ log_debug("Record PID<%u> to file %s.\n", getpid(), pid_file);
}
else
{
- log_err("cannot create %s: %s\n", pid_file, strerror(errno));
+ log_error("cannot create %s: %s\n", pid_file, strerror(errno));
return -1;
}
@@ -257,7 +259,7 @@
}
else
{
- log_err("Can't open PID record file %s: %s\n", pid_file, strerror(errno));
+ log_error("Can't open PID record file %s: %s\n", pid_file, strerror(errno));
return -1;
}
return pid;
@@ -356,11 +358,11 @@
int set_daemon_running(const char *pid_file)
{
daemonize(0, 1);
- log_nrml("Program running as daemon [PID:%d].\n", getpid());
+ log_info("Program running as daemon [PID:%d].\n", getpid());
if (record_daemon_pid(pid_file) < 0)
{
- log_err("Record PID to file \"%s\" failure.\n", pid_file);
+ log_error("Record PID to file \"%s\" failure.\n", pid_file);
return -2;
}
--
Gitblit v1.9.1