/* Remove PID file */ int mk_utils_remove_pid() { mk_user_undo_uidgid(); if (unlink(mk_config->pid_file_path)) { mk_warn("cannot delete pidfile\n"); } mk_config->pid_status = MK_FALSE; return 0; }
/* Remove PID file */ int mk_utils_remove_pid() { unsigned long len = 0; char *filepath = NULL; mk_string_build(&filepath, &len, "%s.%d", config->pid_file_path, config->serverport); mk_user_undo_uidgid(); if (unlink(filepath)) { mk_warn("cannot delete pidfile\n"); } mk_mem_free(filepath); config->pid_status = MK_FALSE; return 0; }
/* when we catch a signal and want to exit we call this function to do it gracefully */ static void mk_signal_exit() { /* ignore future signals to properly handle the cleanup */ signal(SIGTERM, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGHUP, SIG_IGN); mk_user_undo_uidgid(); mk_utils_remove_pid(mk_config->path_conf_pidfile); mk_exit_all(); mk_info("Exiting... >:("); _exit(EXIT_SUCCESS); }
/* Remove PID file */ int mk_utils_remove_pid() { unsigned long len = 0; char *filepath = NULL; struct mk_config_listener *listen; listen = mk_list_entry_first(&config->listeners, struct mk_config_listener, _head); mk_string_build(&filepath, &len, "%s.%s", config->pid_file_path, listen->port); mk_user_undo_uidgid(); if (unlink(filepath)) { mk_warn("cannot delete pidfile\n"); } mk_mem_free(filepath); config->pid_status = MK_FALSE; return 0; }