Skip to content
Snippets Groups Projects
Commit e63b3a63 authored by Andy Green's avatar Andy Green
Browse files

daemonize: use pid_t

parent 8a4b7246
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ lws_create_context(const struct lws_context_creation_info *info)
struct lws_context *context = NULL;
struct lws_plat_file_ops *prev;
#ifndef LWS_NO_DAEMONIZE
int pid_daemon = get_daemonize_pid();
pid_t pid_daemon = get_daemonize_pid();
#endif
#if defined(LWS_WITH_NETWORK)
int n;
......@@ -161,7 +161,7 @@ lwsl_info("context created\n");
#ifndef LWS_NO_DAEMONIZE
if (pid_daemon) {
context->started_with_parent = pid_daemon;
lwsl_info(" Started with daemon pid %d\n", pid_daemon);
lwsl_info(" Started with daemon pid %u\n", (unsigned int)pid_daemon);
}
#endif
#if defined(__ANDROID__)
......
......@@ -356,7 +356,9 @@ struct lws_context {
int max_fds;
int count_event_loop_static_asset_handles;
int started_with_parent;
#if !defined(LWS_NO_DAEMONIZE)
pid_t started_with_parent;
#endif
int uid, gid;
int fd_random;
......
......@@ -28,10 +28,10 @@
#include "core/private.h"
unsigned int pid_daemon;
pid_t pid_daemon;
static char *lock_path;
int get_daemonize_pid()
pid_t get_daemonize_pid()
{
return pid_daemon;
}
......
......@@ -199,8 +199,10 @@ lws_plat_service(struct lws_context *context, int timeout_ms)
void
lws_plat_service_periodic(struct lws_context *context)
{
#if !defined(LWS_NO_DAEMONIZE)
/* if our parent went down, don't linger around */
if (context->started_with_parent &&
kill(context->started_with_parent, 0) < 0)
kill(getpid(), SIGTERM);
#endif
}
......@@ -371,9 +371,6 @@ int main(int argc, char **argv)
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
#if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;
#endif
case 'u':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment