本文整理汇总了C++中siglongjmp函数的典型用法代码示例。如果您正苦于以下问题:C++ siglongjmp函数的具体用法?C++ siglongjmp怎么用?C++ siglongjmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了siglongjmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sig_usr1
static void
sig_usr1(int signo)
{
time_t starttime;
if (canjump == 0)
return;
/* unexpected signal, ignore */
pr_mask("starting sig_usr1: ");
alarm(3);
/* SIGALRM in 3 seconds */
starttime = time(NULL);
for (;;)
/* busy wait for 5 seconds */
if (time(NULL) > starttime + 5)
break;
pr_mask("finishing sig_usr1: ");
canjump = 0;
siglongjmp(jmpbuf, 1);
/* jump back to main, don't return */
}
示例2: sigbus_hdl
static void sigbus_hdl(int sig, siginfo_t *si, void *ptr)
{
switch (si->si_code) {
case BUS_MCEERR_AO:
fprintf(stderr, "%s: BUS_MCEERR_AO addr: %p len: %d\n",
__func__, si->si_addr, 1 << si->si_addr_lsb);
sig_mcerr_ao++;
break;
case BUS_MCEERR_AR:
fprintf(stderr, "%s: BUS_MCEERR_AR addr: %p len: %d\n",
__func__, si->si_addr, 1 << si->si_addr_lsb);
sig_mcerr_ar++;
break;
default:
sig_count++;
break;
}
siglongjmp(sj_env, 1);
}
示例3: exception_throw
static void exception_throw(chk_expn_frame *frame,const char *exception,siginfo_t* info) {
int32_t sig = 0;
chk_expn_thd *expthd = chk_exp_get_thread_expn();
if(!frame) {
expthd->sz = backtrace(expthd->bt, LOG_STACK_SIZE);
expthd->exception = exception;
expthd->addr = info->si_addr;
frame = chk_exp_top();
}
if(frame) {
frame->is_process = 0;
if(exception == segfault) sig = SIGSEGV;
else if(exception == sigbug) sig = SIGBUS;
else if(exception == sigfpe) sig = SIGFPE;
siglongjmp(frame->jumpbuffer,sig);
}else {
chk_exp_log_exption_stack();
//没有try,直接终止进程
exit(0);
}
}
示例4: ckptRestoreStack
int
ckptRestoreStack(ckptImage * image, size_t size, void *stack_start)
{
int dummy;
if ((void *)&dummy > (void *)((char *)stack_start - size - 2*STACK_GAP))
ckptRestoreStack(image, size, stack_start);
/* Here we do some hack, reading directly from file, but there's no
other way here */
dummy = image->fd;
F_REAL_READ(image->fd, (void *)((char *)stack_start - size - STACK_GAP), size);
F_REAL_CLOSE(dummy);
ckptSystemIgnore--;
siglongjmp(ckptJumpBuffer, 1);
/* XXX: to make compiler happy */
return 0;
}
示例5: handler
static void
handler(int sig)
{
/* UNSAFE: This handler uses non-async-signal-safe functions
(printf(), strsignal(), printSigMask(); see Section 21.1.2) */
printf("Received signal %d (%s), signal mask is:\n", sig,
strsignal(sig));
printSigMask(stdout, NULL);
if (!canJump) {
printf("'env' buffer not yet set, doing a simple return\n");
return;
}
#ifdef USE_SIGSETJMP
siglongjmp(senv, 1);
#else
longjmp(env, 1);
#endif
}
示例6: coroutine_trampoline
static void coroutine_trampoline(int i0, int i1)
{
union cc_arg arg;
CoroutineUContext *self;
Coroutine *co;
arg.i[0] = i0;
arg.i[1] = i1;
self = arg.p;
co = &self->base;
/* Initialize longjmp environment and switch back the caller */
if (!sigsetjmp(self->env, 0)) {
siglongjmp(*(sigjmp_buf *)co->entry_arg, 1);
}
while (true) {
co->entry(co->entry_arg);
qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE);
}
}
示例7: sig_hldr
void sig_hldr(int signal, siginfo_t *si, void *arg)
{
pthread_t id;
int i;
//printf("Caught segfault at address %p ", si->si_addr);
id = pthread_self();
printf("\n thread id = %lu\n",id);
for (i = 0; i < gloc; i++)
{
if (tid[i] == id)
break;
}
if (i >= gloc)
printf("\nmain thread: caught signal %d\n", signal);
else
printf("\nthread no %d: thread id %lu: caught signal %d\n", i+1, id, signal);
siglongjmp(env, i+1);
return;
}
示例8: sigtstp
/* SIGTSTP handler. This function care user's ^Z input. */
void
sigtstp (int sig)
{
/* Execute "end" command. */
vtysh_execute ("end");
/* Initialize readline. */
rl_initialize ();
printf ("\n");
/* Check jmpflag for duplicate siglongjmp(). */
if (! jmpflag)
return;
/* vtysh_kill_more();*/
jmpflag = 0;
/* Back to main command loop. */
siglongjmp (jmpbuf, 1);
}
示例9: fatal_error_handler
static void
fatal_error_handler (j_common_ptr cinfo)
{
struct error_handler_data *errmgr;
char buffer[JMSG_LENGTH_MAX];
errmgr = (struct error_handler_data *) cinfo->err;
/* Create the message */
(* cinfo->err->format_message) (cinfo, buffer);
if ((errmgr->error != NULL) && (*errmgr->error == NULL))
g_set_error (errmgr->error,
JPEG_ERROR,
JPEG_ERROR_FAILED,
"Error interpreting JPEG image\n\n%s",
buffer);
siglongjmp (errmgr->setjmp_buffer, 1);
g_assert_not_reached ();
}
示例10: sig_usr1
static void
sig_usr1(int signo)
{
time_t starttime;
if (canjump == 0)
return; // unexpected signal, ignore
pr_mask("starting sig_usr1: ");
alarm(3);
starttime = time(NULL);
for (;;) // busy wait for 5 seconds
if (time(NULL) > starttime + 5)
break;
pr_mask("finishing sig_usr1: ");
canjump = 0;
siglongjmp(jmpbuf, 1);
}
示例11: error
VCSI_OBJECT error(VCSI_CONTEXT vc,
char* text,
VCSI_OBJECT obj) {
#ifdef DEBUG
printf("Error: %s - %s\n",text,print_obj(vc,vc->tmpstr,obj,1));
#endif
#ifdef WITH_THREADS
pthread_mutex_lock(vc->error_mutex);
#endif
vc->errobj->type = SYMBOL;
VCELL(vc->errobj) = cons(vc,make_string(vc,text),cons(vc,obj,NULL));
vc->got_error = 1;
#ifdef WITH_THREADS
pthread_mutex_unlock(vc->error_mutex);
#endif
siglongjmp(DYNERR(vc->root_wind),1);
return vc->errobj;
}
示例12: timer
static void timer(int signum)
{
(void)signum;
logmsg("alarm!");
timeout += rexmtval;
if(timeout >= maxtimeout) {
if(wrotepidfile) {
wrotepidfile = 0;
unlink(pidname);
}
if(serverlogslocked) {
serverlogslocked = 0;
clear_advisor_read_lock(SERVERLOGS_LOCK);
}
exit(1);
}
#ifdef HAVE_SIGSETJMP
siglongjmp(timeoutbuf, 1);
#endif
}
示例13: catch_signals
void
catch_signals(int signo)
{
switch(signo)
{
case SIGUSR1:
quitflag++; // signal to the timer loop
break;
case SIGSEGV:
siglongjmp(env, 1);// jump back to the setjmp() point
break;
case SIGTERM:
gFrame->Close();
break;
default:
break;
}
}
示例14: sage_interrupt_handler
/* Handler for SIGHUP, SIGINT */
void sage_interrupt_handler(int sig)
{
#if ENABLE_DEBUG_INTERRUPT
if (sage_interrupt_debug_level >= 1) {
fprintf(stderr, "\n*** SIG %i *** %s sig_on\n", sig, (_signals.sig_on_count > 0) ? "inside" : "outside");
if (sage_interrupt_debug_level >= 3) print_backtrace();
fflush(stderr);
/* Store time of this signal, unless there is already a
* pending signal. */
if (!_signals.interrupt_received) gettimeofday(&sigtime, NULL);
}
#endif
if (_signals.sig_on_count > 0)
{
if (!_signals.block_sigint)
{
/* Actually raise an exception so Python can see it */
sig_raise_exception(sig);
/* Jump back to sig_on() (the first one if there is a stack) */
reset_CPU();
siglongjmp(_signals.env, sig);
}
}
else
{
/* Set the Python interrupt indicator, which will cause the
* Python-level interrupt handler in sage/ext/c_lib.pyx to be
* called. */
PyErr_SetInterrupt();
}
/* If we are here, we cannot handle the interrupt immediately, so
* we store the signal number for later use. But make sure we
* don't overwrite a SIGHUP or SIGTERM which we already received. */
if (_signals.interrupt_received != SIGHUP && _signals.interrupt_received != SIGTERM)
_signals.interrupt_received = sig;
}
示例15: hilo5
void hilo5(){
sigsetjmp(env_5,1);
if (h5==0) {
}
else{
end_h5=0;
static int i=0;
static float j=0;
static long double acc=1.0;
acc_h5=0.0;
while(1){
int returned_from_longjump=1;
if ((returned_from_longjump = sigsetjmp(env_5,1)) ==0){
siglongjmp(env_sc,1);}
if (end_h5==0){
for(i=1;i<n_5+1;i++){
sigsetjmp(env_5,1);
acc=1.0;
for (j=2*i;j>i;j--){
acc*=j/(4*(j-i));
}
porcentajehilo5actual = i*57/n_5;
acc=acc/(2*i+1);
acc_h5=acc_h5+acc;
}
end_h5=1;
}
}
}
}