2019-06-30 00:01:37 +08:00
|
|
|
/* Pi-hole: A black hole for Internet advertisements
|
|
|
|
* (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
|
|
|
* Network-wide ad blocking via your own hardware.
|
|
|
|
*
|
|
|
|
* FTL Engine
|
|
|
|
* Daemon prototypes
|
|
|
|
*
|
|
|
|
* This file is copyright under the latest version of the EUPL.
|
|
|
|
* Please see LICENSE file for your rights under this license. */
|
|
|
|
#ifndef DAEMON_H
|
|
|
|
#define DAEMON_H
|
|
|
|
|
2021-03-16 20:42:34 +08:00
|
|
|
#include "enums.h"
|
|
|
|
extern pthread_t threads[THREADS_MAX];
|
2022-07-30 19:53:02 +08:00
|
|
|
#define MAX_API_THREADS 5
|
2022-08-20 20:50:57 +08:00
|
|
|
extern pthread_t api_threads[MAX_API_THREADS];
|
2021-03-16 20:42:34 +08:00
|
|
|
|
2019-06-30 00:01:37 +08:00
|
|
|
void go_daemon(void);
|
|
|
|
void savepid(void);
|
2021-02-17 18:46:36 +08:00
|
|
|
char *getUserName(void);
|
2021-04-16 17:19:45 +08:00
|
|
|
const char *hostname(void);
|
2020-03-25 00:20:13 +08:00
|
|
|
void delay_startup(void);
|
2020-06-26 15:30:12 +08:00
|
|
|
bool is_fork(const pid_t mpid, const pid_t pid) __attribute__ ((const));
|
2021-02-17 18:46:36 +08:00
|
|
|
void cleanup(const int ret);
|
2020-06-26 15:30:12 +08:00
|
|
|
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
// Get ID of current thread (incorrectly shown as "PID" in, e.g., htop)
|
|
|
|
// We define this wrapper ourselves as the GNU C Library only added it
|
|
|
|
// in 2019 meaning that, while we're writing this, it will not be widely
|
|
|
|
// available. It was only added even later (end of 2019) to musl libc.
|
|
|
|
// https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
|
|
|
|
// https://www.openwall.com/lists/musl/2019/08/01/11
|
|
|
|
// To avoid any conflicts, also in the future, we use our own macro for this
|
|
|
|
#if !defined(SYS_gettid) && defined(__NR_gettid)
|
|
|
|
#define SYS_gettid __NR_gettid
|
|
|
|
#endif // !SYS_gettid && __NR_gettid
|
|
|
|
pid_t FTL_gettid(void);
|
|
|
|
#define gettid FTL_gettid
|
2019-06-30 00:01:37 +08:00
|
|
|
|
2020-05-19 04:56:55 +08:00
|
|
|
extern bool resolver_ready;
|
|
|
|
|
2019-06-30 00:01:37 +08:00
|
|
|
#endif //DAEMON_H
|