• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ do_shutdown函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中do_shutdown函数的典型用法代码示例。如果您正苦于以下问题:C++ do_shutdown函数的具体用法?C++ do_shutdown怎么用?C++ do_shutdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了do_shutdown函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse

/* Standard reboot/shutdown utilities talk to init using /dev/initctl.
 * We should check if the fifo was recreated and reopen it.
 */
static void parse(void *UNUSED(arg), int fd, int UNUSED(events))
{
	struct init_request rq;

	_d("Receiving request on %s...", FINIT_FIFO);
	while (1) {
		ssize_t len = read(fd, &rq, sizeof(rq));

		if (len <= 0) {
			if (-1 == len) {
				if (EINTR == errno)
					continue;

				if (EAGAIN == errno)
					break;

				_e("Failed reading initctl request, error %d: %s", errno, strerror(errno));
			}
			break;
		}

		if (rq.magic != INIT_MAGIC || len != sizeof(rq)) {
			_e("Invalid initctl request.");
			break;
		}

		_d("Magic OK...");
		if (rq.cmd == INIT_CMD_RUNLVL) {
			switch (rq.runlevel) {
			case '0':
				_d("Halting system (SIGUSR2)");
				do_shutdown(SIGUSR2);
				break;

			case 's':
			case 'S':
				rq.runlevel = '1';
				/* Fall through to regular processing */
			case '1'...'5':
				_d("Setting new runlevel %c ...", rq.runlevel);
				svc_runlevel(rq.runlevel - '0');
				break;

			case '6':
				_d("Rebooting system (SIGUSR1)");
				do_shutdown(SIGUSR1);
				break;

			default:
				_d("Unsupported runlevel: %d", rq.runlevel);
				break;
			}
		} else if (rq.cmd == INIT_CMD_DEBUG) {
			debug = !debug;
		} else {
			_d("Unsupported cmd: %d", rq.cmd);
		}
	}
开发者ID:cmatsuoka,项目名称:finit,代码行数:61,代码来源:initctl.c


示例2: board_status_probe

/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :  standby_mode: 0, 普通模式,需要检测电源状态
*
*					                1, 测试模式,强制进入standby模式,不论电源状态
*
*    return        :
*
*    note          :  probe power and other condition
*
*
*
************************************************************************************************************
*/
void board_status_probe(int standby_mode)
{
	int ret;

	//清除power按键
	axp_probe_key();
	//启动条件判断,第一阶段,检测电源电压状态
	if(!standby_mode)
	{
		ret = board_probe_power_level();	//负数:关机;0:进入系统;正数:待机
		debug("stage1 resule %d\n", ret);
		if(ret < 0)
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
		else if(!ret)
		{
			return ;
		}
		//启动条件判断,第二阶段,检测开机原因
		ret = board_probe_poweron_cause();		//负数,0:进入系统;正数:待机或者直接关机
		debug("stage2 resule %d\n", ret);
		if(ret <= 0)
		{
			return ;
		}
		else if(ret == AXP_VBUS_DCIN_NOT_EXIST) //当前一次为boot standby状态,但是启动时检查无外部电源,直接关机
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
	}
	//启动条件判断,第三阶段,检测电池存在
	//负数:关机;0:进入系统;正数:待机
	ret = board_probe_bat_status(standby_mode);
	debug("stage3 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}
	else if(!ret)
	{
		return ;
	}
	//启动条件判断,第四阶段,进入boot待机
	//负数:关机,其它:进入系统
	ret = board_standby_status(ret);
	debug("stage4 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}

	return ;
}
开发者ID:tempbottle,项目名称:InDashNet.Open.UN2000,代码行数:73,代码来源:load_check.c


示例3: do_abort

/**
 * abort task to run on test timed out
 *
 * @param cls NULL
 * @param tc the task context
 */
static void
do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting\n");
  abort_task = NULL;
  do_shutdown (cls, tc);
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:13,代码来源:test_testbed_api_controllerlink.c


示例4: ds1287_issue_shutdown

static uint_t
ds1287_issue_shutdown(caddr_t arg)
{
	struct ds1287 *softsp = (struct ds1287 *)arg;

	DPRINTF("ds1287_issue_shutdown\n");

	mutex_enter(&softsp->ds1287_mutex);
	softsp->events |= PB_BUTTON_PRESS;
	if (softsp->monitor_on != 0) {
		mutex_exit(&softsp->ds1287_mutex);
		pollwakeup(&softsp->pollhd, POLLRDNORM);
		pollwakeup(&softsp->pollhd, POLLIN);
		return (DDI_INTR_CLAIMED);
	}

	if (!softsp->shutdown_pending) {
		cmn_err(CE_WARN, "Power button is pressed, powering down "
		    "the system!");
		softsp->shutdown_pending = 1;
		do_shutdown();

		/*
		 * Wait a while for "do_shutdown()" to shut down the system
		 * before logging an error message.
		 */
		(void) timeout((void(*)(void *))ds1287_log_message, NULL,
		    100 * hz);
	}
	mutex_exit(&softsp->ds1287_mutex);

	return (DDI_INTR_CLAIMED);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:33,代码来源:todds1287.c


示例5: do_switches

// this just wraps ALL the code in total catch block
int Kernel::run(int argc, const char* argv[], const std::string& appName)
{
    m_argc = argc;
    m_argv = argv;
    m_appName = appName;

    int switches_status = do_switches();
    if (switches_status)
        return switches_status;

    int startup_status = do_startup();
    if (startup_status)
        return startup_status;

    int execution_status = do_execution();

    // note we will try to shutdown cleanly even if we got an error condition
    // in the execution phase

    int shutdown_status = do_shutdown();

    if (execution_status)
        return execution_status;

    return shutdown_status;
}
开发者ID:rskelly,项目名称:PDAL,代码行数:27,代码来源:Kernel.cpp


示例6: shutdown_handler

/*
 * Shut down on INT USR1 USR2
 */
static void shutdown_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
{
	_d("Rebooting on signal %d from %s (PID %d)",
	   sig, pid_get_name(info->si_pid, NULL, 0), info->si_pid);

	do_shutdown(sig);
}
开发者ID:benatto,项目名称:finit,代码行数:10,代码来源:sig.c


示例7: do_abort

/**
 * abort task to run on test timed out
 *
 * @param cls NULL
 * @param tc the task context
 */
static void
do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
  abort_task = GNUNET_SCHEDULER_NO_TASK;
  do_shutdown (cls, tc);
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:13,代码来源:test_testbed_api_controllerlink.c


示例8: do_abort

/**
 * abort task to run on test timed out
 *
 * @param cls NULL
 * @param tc the task context
 */
static void
do_abort (void *cls)
{
  LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
  abort_task = NULL;
  do_shutdown (cls);
}
开发者ID:GNUnet,项目名称:gnunet,代码行数:13,代码来源:test_testbed_api.c


示例9: ctrl_c_shutdown

static void
ctrl_c_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  ctrl_c_task_id = NULL;
  do_shutdown ();
  GNUNET_break (0);
  global_ret = 1;
}
开发者ID:tg-x,项目名称:gnunet,代码行数:8,代码来源:test_gnunet_vpn.c


示例10: do_deferred_shutdown

static void
do_deferred_shutdown (DskWebsocket *websocket)
{
  if (websocket->outgoing.size == 0)
    do_shutdown (websocket);
  else
    websocket->is_deferred_shutdown = DSK_TRUE;
}
开发者ID:davebenson,项目名称:dsk,代码行数:8,代码来源:dsk-websocket.c


示例11: do_abort

/**
 * Shutdown nicely
 *
 * @param cls
 * @param tc the task context
 */
static void
do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  LOG (GNUNET_ERROR_TYPE_DEBUG, "Aborting test...\n");
  abort_task_id = GNUNET_SCHEDULER_NO_TASK;
  result = TEST_FAIL;
  do_shutdown (cls, tc);
}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:14,代码来源:test_lockmanager_api.c


示例12: main

/*
 *	Main program.
 *	Write a wtmp entry and reboot cq. halt.
 */
int main(int argc, char **argv)
{
	int do_sync = 1;
	int do_hard = 0;
	int do_ifdown = 0;
	int c;

	/*
	 *	Get flags
	 */
	while((c = getopt(argc, argv, ":ifn:")) != EOF) {
		switch(c) {
			case 'n':
				do_sync = 0;
				break;
			case 'f':
				do_hard = 1;
				break;
			case 'i':
				do_ifdown = 1;
				break;
			default:
				usage();
		}
	 }
	if (argc == optind) usage();

	if (geteuid() != 0) {
		fprintf(stderr, "%s: must be superuser.\n", progname);
		exit(1);
	}

	(void)chdir("/");

	if (!do_hard ) {
		/*
		 *	See if we are in runlevel 0 or 6.
		 */
		c = get_runlevel();
		if (c != '0' && c != '6')
			do_shutdown(argv[optind]);
	}

	if (do_sync) {
		sync();
		sleep(2);
	}

	if (do_ifdown)
		(void)ifdown();

    (void)hdflush();

    syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
            LINUX_REBOOT_CMD_RESTART2, argv[optind]);

	return 0;
}
开发者ID:rafaello7,项目名称:Novo7Tools,代码行数:62,代码来源:android-reboot.c


示例13: dialog_ok

void dialog_ok(GtkWidget *widget, gpointer data)
{
	const gchar *title = (const gchar *)data;
	if(!g_strcasecmp(title, item_labels[2]))
		do_reboot();
	else if(!g_strcasecmp(title, item_labels[3]))
		do_shutdown();					

}
开发者ID:cherry-wb,项目名称:quietheart,代码行数:9,代码来源:main.c


示例14: main

int
main (int argc, char *argv[])
{
    if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable",
                                      "test_fs_namespace_data.conf",
                                      &run, NULL))
        return 1;
    do_shutdown ();
    return err;
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:10,代码来源:test_fs_namespace_list_updateable.c


示例15: do_stop

static void do_stop(struct cardstate *cs)
{
	unsigned long flags;

	spin_lock_irqsave(&cs->lock, flags);
	cs->connected = 0;
	spin_unlock_irqrestore(&cs->lock, flags);

	do_shutdown(cs);
}
开发者ID:020gzh,项目名称:linux,代码行数:10,代码来源:ev-layer.c


示例16: main

int main(int argc, char **argv)
{
	int status;

	wrapper_argc = argc;
	wrapper_argv = argv;

	--argc; ++argv;
	init(argc, argv);

	struct sigaction sa;
	memset(&sa, 0, sizeof(struct sigaction));
	sa.sa_handler = &signal_handler;
	sigaction(SIGUSR2, &sa, NULL);
	sigaction(SIGHUP, &sa, NULL);
	sigaction(SIGINT, &sa, NULL);
	sigaction(SIGTERM, &sa, NULL);

	if (getenv(REEXEC_FLAG) != NULL) {
		/* We are being re-executed: restart HAProxy gracefully */
		int i;
		char **pid_strv = NULL;
		int nb_pid = read_pids(&pid_strv);

		unsetenv(REEXEC_FLAG);
		spawn_haproxy(pid_strv, nb_pid);

		for (i = 0; i < nb_pid; ++i)
			free(pid_strv[i]);
		free(pid_strv);
	}
	else {
		/* Start a fresh copy of HAProxy */
		spawn_haproxy(NULL, 0);
	}

	status = -1;
	while (caught_signal || wait(&status) != -1 || errno == EINTR) {
		int sig = caught_signal;

		if (caught_signal == SIGUSR2 || caught_signal == SIGHUP) {
			caught_signal = 0;
			do_restart(sig);
		}
		else if (caught_signal == SIGINT || caught_signal == SIGTERM) {
			caught_signal = 0;
			do_shutdown(sig);
		}
	}

	fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: exit, haproxy RC=%d\n",
			status);
	return status;
}
开发者ID:ebuzzing,项目名称:haproxy-1.5,代码行数:54,代码来源:haproxy-systemd-wrapper.c


示例17: desslify

static void desslify(struct context *ctx, int cur)
{
    if (ctx->cbufo && ctx->cbufo->length - ctx->cbufo->offset)
	control2socket(ctx, cur);
    if (ctx->cbufo && ctx->cbufo->length - ctx->cbufo->offset)
	io_set_cb_o(ctx->io, cur, (void *) do_shutdown);
    else {
	io_clr_i(ctx->io, cur);
	io_clr_o(ctx->io, cur);
	do_shutdown(ctx, cur);
    }
}
开发者ID:hydrix1,项目名称:tacacs,代码行数:12,代码来源:h_rein.c


示例18: sef_cb_signal_handler

/*===========================================================================*
 *		            sef_cb_signal_handler                            *
 *===========================================================================*/
PRIVATE void sef_cb_signal_handler(int signo)
{
  /* Check for known signals, ignore anything else. */
  switch(signo) {
      case SIGCHLD:
          do_sigchld();
      break;
      case SIGTERM:
          do_shutdown(NULL);
      break;
  }
}
开发者ID:mwilbur,项目名称:minix,代码行数:15,代码来源:main.c


示例19: sig_handler

/*===========================================================================*
 *				sig_handler                                  *
 *===========================================================================*/
PRIVATE void sig_handler()
{
  sigset_t sigset;
  int sig;

  /* Try to obtain signal set from PM. */
  if (getsigset(&sigset) != 0) return;

  /* Check for known signals. */
  if (sigismember(&sigset, SIGCHLD)) do_exit(NULL);
  if (sigismember(&sigset, SIGTERM)) do_shutdown(NULL);
}
开发者ID:BiancoZandbergen,项目名称:RTMINIX3,代码行数:15,代码来源:main.c


示例20: shutdown_task

/**
 * Task run for shutdown.
 *
 * @param cls closure, NULL if we need to self-restart
 * @param tc context
 */
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct ServiceList *pos;
  struct ServiceList *nxt;
  struct ServiceListeningInfo *sli;

  if (GNUNET_SCHEDULER_NO_TASK != child_restart_task)
  {
    GNUNET_SCHEDULER_cancel (child_restart_task);
    child_restart_task = GNUNET_SCHEDULER_NO_TASK;
  }
  in_shutdown = GNUNET_YES;
  /* first, stop listening */
  for (pos = running_head; NULL != pos; pos = pos->next)
  {
    while (NULL != (sli = pos->listen_head))
      {
	GNUNET_CONTAINER_DLL_remove (pos->listen_head,
				     pos->listen_tail, sli);
	if (sli->accept_task != GNUNET_SCHEDULER_NO_TASK)
	  {
	    GNUNET_SCHEDULER_cancel (sli->accept_task);
	    sli->accept_task = GNUNET_SCHEDULER_NO_TASK;
	  }
	GNUNET_break (GNUNET_OK ==
		      GNUNET_NETWORK_socket_close (sli->listen_socket));
	GNUNET_free (sli->service_addr);
	GNUNET_free (sli);
      }
  }
  /* then, shutdown all existing service processes */
  nxt = running_head;
  while (NULL != (pos = nxt))
  {
    nxt = pos->next;
    if (pos->proc != NULL)
    {
      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n",
		  pos->name);
      pos->killed_at = GNUNET_TIME_absolute_get ();
      if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
	GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
    }
    else
    {
      free_service (pos);
    }
  }
  /* finally, should all service processes be already gone, terminate for real */
  if (running_head == NULL)
    do_shutdown ();
}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:59,代码来源:gnunet-service-arm.c



注:本文中的do_shutdown函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ do_sigaltstack函数代码示例发布时间:2022-05-30
下一篇:
C++ do_settimeofday函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap