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

C++ CatchSignal函数代码示例

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

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



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

示例1: fault_report

/*******************************************************************
report a fault
********************************************************************/
static void fault_report(int sig)
{
	static int counter;

	if (counter)
        abort();

	counter++;

	LOG(log_severe, logtype_default, "===============================================================");
	LOG(log_severe, logtype_default, "INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION);
	LOG(log_severe, logtype_default, "===============================================================");
  
	netatalk_panic("internal error");

	if (cont_fn) {
		cont_fn(NULL);
#ifdef SIGSEGV
		CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
#endif
#ifdef SIGBUS
		CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
#endif
		return; /* this should cause a core dump */
	}
    abort();
}
开发者ID:BrianHoldsworth,项目名称:netatalk2,代码行数:30,代码来源:fault.c


示例2: fault_report

/*******************************************************************
report a fault
********************************************************************/
static void fault_report(int sig)
{
	static int counter;

	if (counter) _exit(1);

	counter++;

	DEBUGSEP(0);
	DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
	DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba3-HOWTO\n"));
	DEBUG(0,("\nFrom: http://www.samba.org/samba/docs/Samba3-HOWTO.pdf\n"));
	DEBUGSEP(0);
  
	smb_panic("internal error");

	if (cont_fn) {
		cont_fn(NULL);
#ifdef SIGSEGV
		CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
#endif
#ifdef SIGBUS
		CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
#endif
#ifdef SIGABRT
		CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
#endif
		return; /* this should cause a core dump */
	}
	exit(1);
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:34,代码来源:fault.c


示例3: fault_report

/*******************************************************************
report a fault
********************************************************************/
static void fault_report(int sig)
{
	static int counter;

	if (counter) _exit(1);

	counter++;

	DEBUG(0,("===============================================================\n"));
	DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION));
	DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n"));
	DEBUG(0,("===============================================================\n"));
  
	smb_panic("internal error");

	if (cont_fn) {
		cont_fn(NULL);
#ifdef SIGSEGV
		CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
#endif
#ifdef SIGBUS
		CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
#endif
		return; /* this should cause a core dump */
	}
	exit(1);
}
开发者ID:livebox,项目名称:livebox2,代码行数:30,代码来源:fault.c


示例4: do_file_lock

BOOL
do_file_lock (int fd, int waitsecs, int type)
{
    SMB_STRUCT_FLOCK lock;
    int ret;

    gotalarm = 0;
    CatchSignal (SIGALRM, SIGNAL_CAST gotalarm_sig);

    lock.l_type = type;
    lock.l_whence = SEEK_SET;
    lock.l_start = 0;
    lock.l_len = 1;
    lock.l_pid = 0;

    alarm (waitsecs);
    ret = fcntl (fd, SMB_F_SETLKW, &lock);
    alarm (0);
    CatchSignal (SIGALRM, SIGNAL_CAST SIG_DFL);

    if (gotalarm)
    {
        DEBUG (0, ("do_file_lock: failed to %s file.\n", type == F_UNLCK ? "unlock" : "lock"));
        return False;
    }

    return (ret == 0);
}
开发者ID:BrEacK,项目名称:mc,代码行数:28,代码来源:util_file.c


示例5: start_async_dns

/***************************************************************************
  create a child process to handle DNS lookups
  ****************************************************************************/
void start_async_dns(void)
{
	int fd1[2], fd2[2];

	CatchChild();

	if (pipe(fd1) || pipe(fd2)) {
		DEBUG(0,("can't create asyncdns pipes\n"));
		return;
	}

	child_pid = sys_fork();

	if (child_pid) {
		fd_in = fd1[0];
		fd_out = fd2[1];
		close(fd1[1]);
		close(fd2[0]);
		DEBUG(0,("started asyncdns process %d\n", (int)child_pid));
		return;
	}

	fd_in = fd2[0];
	fd_out = fd1[1];

	CatchSignal(SIGUSR2, SIG_IGN);
	CatchSignal(SIGUSR1, SIG_IGN);
	CatchSignal(SIGHUP, SIG_IGN);
        CatchSignal(SIGTERM, SIGNAL_CAST sig_term );

	asyncdns_process();
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:35,代码来源:asyncdns.c


示例6: tdb_chainlock_with_timeout_internal

static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout, int rw_type)
{
	/* Allow tdb_chainlock to be interrupted by an alarm. */
	int ret;
	gotalarm = 0;

	if (timeout) {
		CatchSignal(SIGALRM, gotalarm_sig);
		tdb_setalarm_sigptr(tdb, &gotalarm);
		alarm(timeout);
	}

	if (rw_type == F_RDLCK)
		ret = tdb_chainlock_read(tdb, key);
	else
		ret = tdb_chainlock(tdb, key);

	if (timeout) {
		alarm(0);
		tdb_setalarm_sigptr(tdb, NULL);
		CatchSignal(SIGALRM, SIG_IGN);
		if (gotalarm && (ret != 0)) {
			DEBUG(0,("tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
				timeout, key.dptr, tdb_name(tdb)));
			/* TODO: If we time out waiting for a lock, it might
			 * be nice to use F_GETLK to get the pid of the
			 * process currently holding the lock and print that
			 * as part of the debugging message. -- mbp */
			return -1;
		}
	}

	return ret == 0 ? 0 : -1;
}
开发者ID:ebrainte,项目名称:Samba,代码行数:34,代码来源:util_tdb.c


示例7: do_file_lock

static bool do_file_lock(int fd, int waitsecs, int type)
{
	SMB_STRUCT_FLOCK lock;
	int             ret;
	void (*oldsig_handler)(int);

	gotalarm = 0;
	oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);

	lock.l_type = type;
	lock.l_whence = SEEK_SET;
	lock.l_start = 0;
	lock.l_len = 1;
	lock.l_pid = 0;

	alarm(waitsecs);
	/* Note we must *NOT* use sys_fcntl here ! JRA */
	ret = fcntl(fd, SMB_F_SETLKW, &lock);
	alarm(0);
	CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);

	if (gotalarm && ret == -1) {
		DEBUG(0, ("do_file_lock: failed to %s file.\n",
			type == F_UNLCK ? "unlock" : "lock"));
		return False;
	}

	return (ret == 0);
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:29,代码来源:pdb_smbpasswd.c


示例8: setup_signals

/*
  setup signal masks
*/
static void setup_signals(void)
{
	/* we are never interested in SIGPIPE */
	BlockSignals(true,SIGPIPE);

#if defined(SIGFPE)
	/* we are never interested in SIGFPE */
	BlockSignals(true,SIGFPE);
#endif

	/* We are no longer interested in USR1 */
	BlockSignals(true, SIGUSR1);

#if defined(SIGUSR2)
	/* We are no longer interested in USR2 */
	BlockSignals(true,SIGUSR2);
#endif

	/* POSIX demands that signals are inherited. If the invoking process has
	 * these signals masked, we will have problems, as we won't receive them. */
	BlockSignals(false, SIGHUP);
	BlockSignals(false, SIGTERM);

	CatchSignal(SIGHUP, sig_hup);
	CatchSignal(SIGTERM, sig_term);
}
开发者ID:rti7743,项目名称:samba,代码行数:29,代码来源:server.c


示例9: setup_signals

/*
  setup signal masks
*/
static void setup_signals(void)
{
    /* we are never interested in SIGPIPE */
    BlockSignals(true, SIGPIPE);

#if defined(SIGFPE)
    /* we are never interested in SIGFPE */
    BlockSignals(true, SIGFPE);
#endif

    /* We are no longer interested in USR1 */
    BlockSignals(true, SIGUSR1);

    /* We are no longer interested in SIGINT except for monitor */
    BlockSignals(true, SIGINT);

#if defined(SIGUSR2)
    /* We are no longer interested in USR2 */
    BlockSignals(true, SIGUSR2);
#endif

    /* POSIX demands that signals are inherited. If the invoking process has
     * these signals masked, we will have problems, as we won't receive them. */
    BlockSignals(false, SIGHUP);
    BlockSignals(false, SIGTERM);

#ifndef HAVE_PRCTL
        /* If prctl is not defined on the system, try to handle
         * some common termination signals gracefully */
    CatchSignal(SIGSEGV, sig_segv_abrt);
    CatchSignal(SIGABRT, sig_segv_abrt);
#endif

}
开发者ID:jhrozek,项目名称:sssd,代码行数:37,代码来源:server.c


示例10: lp_cups_connection_timeout

static http_t *cups_connect(TALLOC_CTX *frame)
{
	http_t *http = NULL;
	char *server = NULL, *p = NULL;
	int port;
	int timeout = lp_cups_connection_timeout();
	size_t size;

	if (lp_cups_server(talloc_tos()) != NULL && strlen(lp_cups_server(talloc_tos())) > 0) {
		if (!push_utf8_talloc(frame, &server, lp_cups_server(talloc_tos()), &size)) {
			return NULL;
		}
	} else {
		server = talloc_strdup(frame,cupsServer());
	}
	if (!server) {
		return NULL;
	}

	p = strchr(server, ':');
	if (p) {
		port = atoi(p+1);
		*p = '\0';
	} else {
		port = ippPort();
	}

	DEBUG(10, ("connecting to cups server %s:%d\n",
		   server, port));

	gotalarm = 0;

	if (timeout) {
                CatchSignal(SIGALRM, gotalarm_sig);
                alarm(timeout);
        }

#ifdef HAVE_HTTPCONNECTENCRYPT
	http = httpConnectEncrypt(server, port, lp_cups_encrypt());
#else
	http = httpConnect(server, port);
#endif


	CatchSignal(SIGALRM, SIG_IGN);
        alarm(0);

	if (http == NULL) {
		DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n",
			 server, port, strerror(errno)));
	}

	return http;
}
开发者ID:ebrainte,项目名称:Samba,代码行数:54,代码来源:print_cups.c


示例11: fault_setup

/*******************************************************************
setup our fault handlers
********************************************************************/
void fault_setup(void (*fn)(void *))
{
	cont_fn = fn;

#ifdef SIGSEGV
	CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
#endif
#ifdef SIGBUS
	CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
#endif
}
开发者ID:BrianHoldsworth,项目名称:netatalk2,代码行数:14,代码来源:fault.c


示例12: SendEmoteMessage

void ZSList::WorldShutDown(uint32 time, uint32 interval)
{
	if( time > 0 ) {
		SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down in %i seconds, everyone log out before this time.",time);

		time *= 1000;
		interval *= 1000;
		if(interval < 5000) { interval = 5000; }

		shutdowntimer->SetTimer(time);
		reminder->SetTimer(interval-1000);
		reminder->SetAtTrigger(interval);
		shutdowntimer->Start();
		reminder->Start();
	}
	else {
		SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now.");
		ServerPacket* pack = new ServerPacket;
		pack->opcode = ServerOP_ShutdownAll;
		pack->size=0;
		SendPacket(pack);
		safe_delete(pack);
		Process();
		CatchSignal(2);
	}
}
开发者ID:Corysia,项目名称:Server,代码行数:26,代码来源:zonelist.cpp


示例13: dump_core

 void dump_core(void)
{
	/* Note that even if core dumping has been disabled, we still set up
	 * the core path. This is to handle the case where core dumping is
	 * turned on in smb.conf and the relevant daemon is not restarted.
	 */
	if (!lp_enable_core_files()) {
		DEBUG(0, ("Exiting on internal error (core file administratively disabled\n"));
		exit(1);
	}

	if (*corepath != '\0') {
		/* The chdir might fail if we dump core before we finish
		 * processing the config file.
		 */
		if (chdir(corepath) != 0) {
			DEBUG(0, ("unable to change to %s", corepath));
			DEBUGADD(0, ("refusing to dump core\n"));
			exit(1);
		}

		DEBUG(0,("dumping core in %s\n", corepath));
	}

	umask(~(0700));
	dbgflush();

	/* Ensure we don't have a signal handler for abort. */
#ifdef SIGABRT
	CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
#endif

	abort();
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:34,代码来源:fault.c


示例14: smb_panic

/**
 Something really nasty happened - panic !
**/
_PUBLIC_ _NORETURN_ void smb_panic(const char *why)
{
	int result;

	if (panic_action && *panic_action) {
		char pidstr[20];
		char cmdstring[200];
		safe_strcpy(cmdstring, panic_action, sizeof(cmdstring));
		snprintf(pidstr, sizeof(pidstr), "%u", getpid());
		all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring));
		if (progname) {
			all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring));
		}
		DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring));
		result = system(cmdstring);

		if (result == -1)
			DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
				  strerror(errno)));
		else
			DEBUG(0, ("smb_panic(): action returned status %d\n",
				  WEXITSTATUS(result)));
	}
	DEBUG(0,("PANIC: %s\n", why));

	call_backtrace();

#ifdef SIGABRT
	CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
#endif
	abort();
}
开发者ID:technosaurus,项目名称:samba4-GPL2,代码行数:35,代码来源:fault.c


示例15: AddEQEMuError

void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
	if (!iError)
		return;
	if (!EQEMuErrorList) {
		EQEMuErrorList = new LinkedList<char*>;
		MEQEMuErrorList = new Mutex;
	}
	LockMutex lock(MEQEMuErrorList);

	LinkedListIterator<char*> iterator(*EQEMuErrorList);
	iterator.Reset();
	while (iterator.MoreElements()) {
		if (iterator.GetData()[0] == 1) {
//Umm... this gets a big WTF...
//			if (*((uint32*) iterator.GetData()[1]) == iError)
//not sure whats going on, using a character as a pointer....
			if (*((eEQEMuError*) &(iterator.GetData()[1])) == iError)
				return;
		}
		iterator.Advance();
	}
	
	char* tmp = new char[6];
	tmp[0] = 1;
	tmp[5] = 0;
	*((uint32*) &tmp[1]) = iError;
	EQEMuErrorList->Append(tmp);

	if (iExitNow)
		CatchSignal(2);
}
开发者ID:Lord-Ptolemy,项目名称:projecteqemu,代码行数:31,代码来源:EQEMuError.cpp


示例16: fault_setup

/**
setup our fault handlers
**/
_PUBLIC_ void fault_setup(const char *pname)
{
	if (progname == NULL) {
		progname = pname;
	}
#ifdef SIGSEGV
	CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
#endif
#ifdef SIGBUS
	CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
#endif
#ifdef SIGABRT
	CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
#endif
#ifdef SIGFPE
	CatchSignal(SIGFPE,SIGNAL_CAST sig_fault);
#endif
}
开发者ID:wolfmuel,项目名称:ctdb,代码行数:21,代码来源:fault.c


示例17: dump_core

 void dump_core(void)
{
	static bool called;

	if (called) {
		DEBUG(0, ("dump_core() called recursive\n"));
		exit(1);
	}
	called = true;

	/* Note that even if core dumping has been disabled, we still set up
	 * the core path. This is to handle the case where core dumping is
	 * turned on in smb.conf and the relevant daemon is not restarted.
	 */
	if (!lp_enable_core_files()) {
		DEBUG(0, ("Exiting on internal error (core file administratively disabled)\n"));
		exit(1);
	}

#if DUMP_CORE
	/* If we're running as non root we might not be able to dump the core
	 * file to the corepath.  There must not be an unbecome_root() before
	 * we call abort(). */
	if (geteuid() != 0) {
		become_root();
	}

	if (*corepath != '\0') {
		/* The chdir might fail if we dump core before we finish
		 * processing the config file.
		 */
		if (chdir(corepath) != 0) {
			DEBUG(0, ("unable to change to %s\n", corepath));
			DEBUGADD(0, ("refusing to dump core\n"));
			exit(1);
		}

		DEBUG(0,("dumping core in %s\n", corepath));
	}

	umask(~(0700));
	dbgflush();

	/* Ensure we don't have a signal handler for abort. */
#ifdef SIGABRT
	CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
#endif

	abort();

#else /* DUMP_CORE */
	exit(1);
#endif /* DUMP_CORE */
}
开发者ID:jameshilliard,项目名称:WECB-BH-GPL,代码行数:54,代码来源:fault.c


示例18: sig_usr2

/* ************************************************************************** **
 * catch a sigusr2 - decrease the debug log level.
 * ************************************************************************** **
 */
void sig_usr2( int sig )
  {
  DEBUGLEVEL--;
  if( DEBUGLEVEL < 0 )
    DEBUGLEVEL = 0;

  DEBUG( 0, ( "Got SIGUSR2; set debug level to %d.\n", DEBUGLEVEL ) );

#if !defined(HAVE_SIGACTION)
  CatchSignal( SIGUSR2, SIGNAL_CAST sig_usr2 );
#endif

  } /* sig_usr2 */
开发者ID:pombredanne,项目名称:cliffs,代码行数:17,代码来源:debug.c


示例19: OnSignalProc

// ---------------------------------------------------------------------------
// void OnSignalProc(int s)
//
// handle signal, if signal SIGTERM is received.
// the main process should be shutdown.
// ---------------------------------------------------------------------------
//
void OnSignalProc(int s) {
    const char *funcName = "OnSignalProc";
    LOG(LL_ERROR, "%s::Catch signal :%d", funcName, s);

    if (s == SIGUSR1) {
        LOG(LL_ERROR, "%s::signal :%d", funcName, s);
    } else {
        LOG(LL_ERROR, "%s::Catch signal :%d, exit!!!", funcName, s);
        gIsStoped = true;
        exit(0);
    }
    CatchSignal();
}
开发者ID:PeekOrg,项目名称:minirpc,代码行数:20,代码来源:agent.cpp


示例20: sig_cld_leave_status

static void sig_cld_leave_status(int signum)
{
	/*
	 * Turns out it's *really* important not to
	 * restore the signal handler here if we have real POSIX
	 * signal handling. If we do, then we get the signal re-delivered
	 * immediately - hey presto - instant loop ! JRA.
	 */

#if !defined(HAVE_SIGACTION)
	CatchSignal(SIGCLD, sig_cld_leave_status);
#endif
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:13,代码来源:signal.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Cbuf_AddText函数代码示例发布时间:2022-05-30
下一篇:
C++ CatchException函数代码示例发布时间: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