From c13c9806f957ebc675462737f4b328d3ab89e028 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Mon, 10 Jul 2023 17:29:22 +0800 Subject: [PATCH] update gpsd.c --- gpsd/booster/util_proc.h | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/gpsd/booster/util_proc.h b/gpsd/booster/util_proc.h new file mode 100644 index 0000000..4af3cf2 --- /dev/null +++ b/gpsd/booster/util_proc.h @@ -0,0 +1,67 @@ +/******************************************************************************** + * Copyright: (C) 2020 LingYun IoT System Studio + * All rights reserved. + * + * Filename: util_proc.h + * Description: This head file is for Linux process/thread API + * + * Version: 1.0.0(7/06/2012~) + * Author: Guo Wenxue <guowenxue@gmail.com> + * ChangeLog: 1, Release initial version on "7/06/2012 09:21:33 PM" + * + ********************************************************************************/ + +#ifndef __UTIL_PROC_H_ +#define __UTIL_PROC_H_ + +#include <signal.h> + +#define PID_ASCII_SIZE 11 + +typedef struct proc_signal_s +{ + int signal; + unsigned stop; /* 0: Not term 1: Stop */ +} proc_signal_t; + +typedef void *(* thread_body_t) (void *thread_arg); + +extern proc_signal_t g_signal; + +/* install default signal process functions */ +extern void install_default_signal(void); + +/* excute a linux command by system() */ +extern void exec_system_cmd(const char *format, ...); + +/* check program already running or not, if not then run it and record pid into $pidfile */ +extern int check_set_program_running(int daemon, char *pidfile); + +/* check program already running or not from $pid_file */ +extern int check_daemon_running(const char *pid_file); + +/* set program daemon running and record pid in $pid_file */ +extern int set_daemon_running(const char *pid_file); + +/* record proces ID into $pid_file */ +extern int record_daemon_pid(const char *pid_file); + +/* stop program running from $pid_file */ +extern int stop_daemon_running(const char *pid_file); + +/* my implementation for set program running in daemon */ +extern void daemonize(int nochdir, int noclose); + +/* start a new thread to run $thread_workbody point function */ +extern int thread_start(pthread_t *thread_id, thread_body_t thread_workbody, void *thread_arg); + +/* +---------------------+ + * | Low level API | + * +---------------------+*/ + + + +/* get daemon process ID from $pid_file */ +extern pid_t get_daemon_pid(const char *pid_file); + +#endif -- Gitblit v1.9.1