本文整理汇总了C++中signal_init函数的典型用法代码示例。如果您正苦于以下问题:C++ signal_init函数的具体用法?C++ signal_init怎么用?C++ signal_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了signal_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/* Entry point */
int
main(int argc, char **argv)
{
/* Init debugging level */
mem_allocated = 0;
debug = 0;
/*
* Parse command line and set debug level.
* bits 0..7 reserved by main.c
*/
parse_cmdline(argc, argv);
openlog(PROG, LOG_PID | ((debug & 1) ? LOG_CONS : 0), log_facility);
log_message(LOG_INFO, "Starting " VERSION_STRING);
/* Check if keepalived is already running */
if (keepalived_running(daemon_mode)) {
log_message(LOG_INFO, "daemon is already running");
goto end;
}
if (debug & 1)
enable_console_log();
/* daemonize process */
if (!(debug & 2))
xdaemon(0, 0, 0);
/* write the father's pidfile */
if (!pidfile_write(main_pidfile, getpid()))
goto end;
#ifndef _DEBUG_
/* Signal handling initialization */
signal_init();
#endif
/* Create the master thread */
master = thread_make_master();
/* Init daemon */
start_keepalived();
#ifndef _DEBUG_
/* Launch the scheduling I/O multiplexer */
launch_scheduler();
/* Finish daemon process */
stop_keepalived();
#endif
/*
* Reached when terminate signal catched.
* finally return from system
*/
end:
closelog();
exit(0);
}
示例2: dn_pre_run
static rstatus_t
dn_pre_run(struct instance *nci)
{
rstatus_t status;
status = log_init(nci->log_level, nci->log_filename);
if (status != DN_OK) {
return status;
}
if (daemonize) {
status = dn_daemonize(1);
if (status != DN_OK) {
return status;
}
}
nci->pid = getpid();
status = signal_init();
if (status != DN_OK) {
return status;
}
if (nci->pid_filename) {
status = dn_create_pidfile(nci);
if (status != DN_OK) {
return status;
}
}
dn_print_run(nci);
return DN_OK;
}
示例3: main
int main(int argc, char **argv) {
if (-1 == check_para(argc, argv)) {
PRINTF(LEVEL_ERROR, "check argument error.\n");
return -1;
}
signal_init();
PRINTF(LEVEL_INFORM, "socks5 starting, port: %d\n", g_cfg.port);
g_cfg.fd = socks5_srv_init(g_cfg.port, 10);
if (-1 == g_cfg.fd) {
PRINTF(LEVEL_ERROR, "socks server init error.\n");
return -1;
}
g_cfg.state = SOCKS5_STATE_RUNNING;
g_loop = ev_default_loop(0);
ev_io_init(&g_io_accept, accept_cb, g_cfg.fd, EV_READ);
ev_io_start(g_loop, &g_io_accept);
ev_loop(g_loop, 0);
PRINTF(LEVEL_INFORM, "time to exit.\n");
socks5_srv_exit();
PRINTF(LEVEL_INFORM, "exit socket server.\n");
return 0;
}
示例4: silly_run
void
silly_run(struct silly_config *config)
{
int i;
int err;
pthread_t pid[3];
R.run = 1;
R.exit = 0;
pthread_mutex_init(&R.mutex, NULL);
pthread_cond_init(&R.cond, NULL);
if (config->daemon)
silly_daemon(config);
signal_init();
silly_timer_init();
err = silly_socket_init();
if (err < 0) {
fprintf(stderr, "%s socket init fail:%d\n", config->selfname, err);
exit(-1);
}
silly_worker_init();
srand(time(NULL));
thread_create(&pid[0], thread_socket, NULL);
thread_create(&pid[1], thread_timer, NULL);
thread_create(&pid[2], thread_worker, config);
fprintf(stdout, "%s is running ...\n", config->selfname);
for (i = 0; i < 3; i++)
pthread_join(pid[i], NULL);
pthread_mutex_destroy(&R.mutex);
pthread_cond_destroy(&R.cond);
silly_worker_exit();
silly_timer_exit();
silly_socket_exit();
fprintf(stdout, "%s has already exit...\n", config->selfname);
return ;
}
示例5: test_signal_handler
static int test_signal_handler(const char *argv0, const char *tempdir, int sig)
{
int ret, pid, status;
char err[512] = { 0 };
char crash_log_path[PATH_MAX];
snprintf(crash_log_path, sizeof(crash_log_path), "%s/crash.log.%d",
tempdir, rand());
pid = fork();
if (pid == -1) {
ret = errno;
return ret;
}
else if (pid == 0) {
struct logc lc;
memset(&lc, 0, sizeof(lc));
lc.crash_log_path = crash_log_path;
signal_init(argv0, err, sizeof(err), &lc);
if (err[0]) {
fprintf(stderr, "signal_init error: %s\n", err);
_exit(1);
}
raise(sig);
_exit(1);
}
RETRY_ON_EINTR(ret, waitpid(pid, &status, 0));
EXPECT_ZERO(validate_crash_log(crash_log_path, sig));
return 0;
}
示例6: signal_init
void sdl_application::execute(window& win)
{
signal_init();
SDL_GL_SetSwapInterval(1);
#ifdef EMSCRIPTEN
emscripten_set_main_loop_arg(update_c_function, this, -1, 1);
#else
SDL_GL_SetSwapInterval(0);
while (running)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
update_c_function(this);
SDL_GL_SwapWindow(win.m_window);
}
#endif
signal_quit();
}
示例7: mshell_init
int mshell_init(struct mshell *mshell, int argc, char **argv, char **env)
{
memset(mshell, 0, sizeof(struct mshell));
mshell->user = getpwuid(getuid());
mshell->main_loop = 1;
mshell->is_show_cmdline = 1;
getcwd(mshell->cur_dir, PATH_MAX);
mshell->fd = 0;
mshell->pipe = -1;
mshell->wait_for_childs = 0;
/*需要执行脚本*/
if(argc >= 2) {
mshell->fd = open(argv[1], O_RDONLY);
if(mshell->fd < 0) {
mshell->main_loop = 0;
perror("open");
return 0;
}
mshell->is_show_cmdline = 0;
}
signal_init();
load_env(mshell, env);
return 0;
}
示例8: main
int
main(int argc, char **argv)
{
thread thread_obj;
/* Allocate the room */
req = (REQ *) MALLOC(sizeof (REQ));
/* Command line parser */
if (!parse_cmdline(argc, argv, req)) {
FREE(req);
exit(0);
}
/* Check minimum configuration need */
if (!req->addr_ip && !req->addr_port && !req->url) {
FREE(req);
exit(0);
}
/* Init the reference timer */
req->ref_time = timer_tol(timer_now());
DBG("Reference timer = %lu\n", req->ref_time);
/* Init SSL context */
init_ssl();
/* Signal handling initialization */
signal_init();
/* Create the master thread */
master = thread_make_master();
/* Register the GET request */
init_sock();
/*
* Processing the master thread queues,
* return and execute one ready thread.
* Run until error, used for debuging only.
* Note that not calling launch_scheduler() does
* not activate SIGCHLD handling, however, this
* is no issue here.
*/
while (thread_fetch(master, &thread_obj))
thread_call(&thread_obj);
/* Finalize output informations */
if (req->verbose)
printf("Global response time for [%s] =%lu\n",
req->url, req->response_time - req->ref_time);
/* exit cleanly */
SSL_CTX_free(req->ctx);
free_sock(sock);
FREE(req);
exit(0);
}
示例9: main
int main()
{
struct sigaction *act;
if (!(act = act_init(act)))
my_error(4, 6);
signal_init(act);
print_pid(getpid());
call_next_client(getpid());
}
示例10: init_subsystems
static void init_subsystems()
{
shared_init();
heap_init();
signal_init();
process_init();
tls_init();
vfs_init();
dbt_init();
}
示例11: thread_dup
error_t thread_dup(struct task_s *task,
struct thread_s *dst,
struct cpu_s *dst_cpu,
struct cluster_s *dst_clstr,
struct thread_s *src)
{
register uint_t sched_policy;
register uint_t cpu_lid;
register uint_t cid;
struct page_s *page;
sched_policy = sched_getpolicy(src);
cpu_lid = dst_cpu->lid;
cid = dst_clstr->id;
page = dst->info.page;
// Duplicate
page_copy(page, src->info.page);
// Initialize dst thread
spinlock_init(&dst->lock, "Thread");
dst->flags = 0;
thread_clear_joinable(dst);
dst->locks_count = 0;
dst->ticks_nr = 0;
thread_set_current_cpu(dst, dst_cpu);
sched_setpolicy(dst, sched_policy);
dst->task = task;
dst->type = PTHREAD;
dst->info.sched_nr = 0;
dst->info.ppm_last_cid = cid;
dst->info.migration_cntr = 0;
dst->info.migration_fail_cntr = 0;
dst->info.tm_exec = 0;
dst->info.tm_tmp = 0;
dst->info.tm_usr = 0;
dst->info.tm_sys = 0;
dst->info.tm_sleep = 0;
dst->info.tm_wait = 0;
signal_init(dst);
dst->info.join = NULL;
wait_queue_init(&dst->info.wait_queue, "Join/Exit Sync");
dst->info.attr.sched_policy = sched_policy;
dst->info.attr.cid = cid;
dst->info.attr.cpu_lid = cpu_lid;
dst->info.attr.cpu_gid = dst_cpu->gid;
dst->info.attr.tid = (uint_t) dst;
dst->info.attr.pid = task->pid;
dst->info.kstack_addr = (uint_t*)dst;
dst->info.page = page;
dst->signature = THREAD_ID;
return 0;
}
示例12: init
static void init() {
int initialized = protocol_init() && caps_init() && signal_init() && comm_init() && injectable_init();
if (!initialized) {
fatal("Initialization failed.");
cleanup();
exit(EXIT_FAILURE);
}
}
示例13: main
int main()
{
int fd;
char buf[MAX_MSG_LEN] = {0};
char client_name[128] = {0};
pid_t pid;
signal_init();
sprintf(client_name, "%05d.socket", getpid());
fd = client_conn(SERVER_IPC_DOMAIN_NAME, client_name);
pid = fork();
if (pid < 0)
{
DEBUG_ERR("fork error\n");
}
else if (pid == 0)
{
sprintf(client_name, "%05d.socket", getpid());
fd = client_conn(SERVER_IPC_DOMAIN_NAME, client_name);
if (fd < 0)
{
DEBUG_ERR("create server unix domain socket error\n");
return -1;
}
memset(buf, 0 ,sizeof(buf));
sprintf(buf, "client_name %s", client_name);
write(fd, buf, sizeof(buf));
close(fd);
unlink(client_name);
exit(0);
}
if (fd < 0)
{
DEBUG_ERR("create server unix domain socket error\n");
return -1;
}
sprintf(buf, "client_name %s", client_name);
swriten(fd, buf, sizeof(buf));
close(fd);
unlink(client_name);
return 0;
}
示例14: event_init
void event_init()
{
// Initialize input events
input_init();
// Timer to wake the event loop if a timeout argument is passed to
// `event_poll`
// Signals
signal_init();
uv_timer_init(uv_default_loop(), &timer);
// This prepare handle that actually starts the timer
uv_prepare_init(uv_default_loop(), &timer_prepare);
}
示例15: main
int
main(int argc, char * const argv[])
{
int c;
boolean_t fork = B_TRUE;
progname = basename(strdup(argv[0]));
if ((fmri = (const char *)getenv("SMF_FMRI")) == NULL)
fmri = DEFAULT_FMRI;
(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
while ((c = getopt(argc, argv, "djn")) != EOF) {
switch (c) {
case 'd':
dlevel = 0xffff;
break;
case 'j':
json = B_TRUE;
break;
case 'n':
fork = B_FALSE;
break;
default:
(void) fprintf(stderr, gettext("Unknown option "
"\'%c\'.\n"), c);
usage(progname);
}
}
pid = getpid();
if ((main_port = port_create()) == -1)
err(EXIT_FAILURE, "port_create() failed");
list_create(&links, sizeof (link_t), offsetof(link_t, node));
VERIFY(get_sysinfo());
lldp_read_config();
signal_init();
get_port_list();
lldp_init(4);
cdp_init(4);
main_loop();
return (0);
}