APUE Learning Example Source Code
guowenxue
2023-11-06 d81310d55b9b7d07904c19f879f50e52fd7be489
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/********************************************************************************
 *      Copyright:  (C) 2012 Guo Wenxue<guowenxue@gmail.com>
 *                  All rights reserved.
 *
 *       Filename:  cp_proc.h
 *    Description:  This head file is for Linux process API
 *
 *        Version:  1.0.0(11/06/2012~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "11/06/2012 09:21:33 PM"
 *                 
 ********************************************************************************/
 
#ifndef  _PROC_H_
#define  _PROC_H_
#include <signal.h>
 
#define PID_ASCII_SIZE  11
 
typedef struct proc_signal_s
{
    int       signal;
    unsigned  stop;     /* 0: Not term  1: Stop  */
    int       threads;  /* threads counter */
}  proc_signal_t;
 
extern proc_signal_t     g_signal;
extern void install_proc_signal(void);
 
extern void daemonize(int nochdir, int noclose);
extern int record_daemon_pid(const char *pid_file);
extern pid_t get_daemon_pid(const char *pid_file);
extern int check_daemon_running(const char *pid_file);
extern int stop_daemon_running(const char *pid_file);
extern int set_daemon_running(const char *pid_file);
 
extern void exec_system_cmd(const char *format, ...);
 
typedef void *(* thread_body)(void *thread_arg);
extern int thread_start(pthread_t * thread_id, thread_body worker_func, void *thread_arg);
 
extern void thread_stop(char *prompt);
 
#endif   /* ----- #ifndef _PROC_H_  ----- */