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

C++ siginterrupt函数代码示例

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

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



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

示例1: main

int main (int argc, char *argv[]){
    sigset_t allsignals;

    sigemptyset(&allsignals);
    sigaddset(&allsignals, SIGUSR1);
    //sigprocmask(SIG_UNBLOCK, &usr1set, NULL);

    sigfillset(&allsignals);
    sigprocmask(SIG_BLOCK, &allsignals, NULL);
    fflush(stdout);

    siginterrupt(SIGUSR1,0);
    struct sigaction action, oldaction;
    action.sa_handler=entradadatos;
    action.sa_mask=allsignals;
    action.sa_flags=SA_RESTART;
    sigaction (SIGUSR1,&action, NULL);
    siginterrupt(SIGUSR1,0);

    //(void) signal(SIGUSR1,entradadatos);
    printf("Name sacoboxeo\n");
    printf("Colour F0F0F0 0F0F0F\n");
    printf("RobotOption %i 1\n",USE_NON_BLOCKING);
    printf("RobotOption %i %i\n",SIGNAL,SIGUSR1);
    sigprocmask(SIG_UNBLOCK, &allsignals, NULL);
    while(1){
        fflush(stdout);
    }
return(0);
}
开发者ID:brainsqueezer,项目名称:realtimebattle,代码行数:30,代码来源:sacoboxeo.c


示例2: okay

/*
 * do the "paper work"
 *	- save my own pid in /var/run/$0.{port#}.pid
 */
static void
okay(int pn)
{
	int fd;
	char *p, numbuf[80];

	if (pidfile[0] == '\0') {
		p = rindex(prog, '/');
		p = (p == NULL) ? prog : p + 1;

		snprintf(pidfile, sizeof pidfile,
			"%s%s.%d.pid", _PATH_VARRUN, p, pn);
	}

	fd = open(pidfile, O_WRONLY|O_CREAT|O_EXCL, 0644);
	if (fd < 0) {
		perror(pidfile);
		exit(21);
	}

	siginterrupt(SIGTERM, 1);
	siginterrupt(SIGHUP, 1);
	signal(SIGTERM, quit);
	signal(SIGHUP, quit);
	signal(SIGINT, quit);

	snprintf(numbuf, sizeof numbuf, "%d\n", getpid());
	if (write(fd, numbuf, strlen(numbuf)) < 0) {
		perror(pidfile);
		quit(23);
	}
	(void) close(fd);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:37,代码来源:ipfwpcap.c


示例3: install_signal_handlers

static void install_signal_handlers(void)
{
#ifdef SIGHUP
  /* ignore SIGHUP signal */
  if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
    logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
#endif
#ifdef SIGPIPE
  /* ignore SIGPIPE signal */
  if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
    logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
#endif
#ifdef SIGALRM
  /* ignore SIGALRM signal */
  if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
    logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
#endif
#ifdef SIGINT
  /* handle SIGINT signal with our exit_signal_handler */
  if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
    logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
  else
    siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
  /* handle SIGTERM signal with our exit_signal_handler */
  if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
    logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
  else
    siginterrupt(SIGTERM, 1);
#endif
}
开发者ID:bagobor,项目名称:vs-curl-test,代码行数:32,代码来源:rtspd.c


示例4: gotsignal

void gotsignal(int signum) {
char msg[100];
switch(signum) {
case SIGUSR1:  // kill -s USR1 pid
  signal(SIGUSR1, gotsignal); siginterrupt(SIGUSR1, 0);
  sprintf(msg, "got SIGUSR1 signal:%d\n", signum);
  break;
case SIGINT:
  signal(SIGINT, gotsignal); siginterrupt(SIGINT, 0);
  sprintf(msg, "got SIGINT signal, quitting...:%d\n", signum);
  quit=signum; 
  break;
case SIGQUIT:
  signal(SIGQUIT, gotsignal); siginterrupt(SIGQUIT, 0);
  sprintf(msg, "got SIGQUIT signal, quitting...:%d\n", signum);
  quit=signum; 
  break;
case SIGBUS: 
  //vmeish(); not to be called (if called, it kills dims process)
  sprintf(msg, "got SIGBUS signal:%d\n", signum);
  break; 
default:
  sprintf(msg, "got unknown signal:%d\n", signum);
};
prtLog(msg);
}
开发者ID:juskoa,项目名称:trigger,代码行数:26,代码来源:gcalib.c


示例5: main

int main(int argc, char **argv)  {
infolog_SetFacility((char *)"CTP");
infolog_SetStream("",0);
setlinebuf(stdout);
signal(SIGUSR1, gotsignal); siginterrupt(SIGUSR1, 0);
signal(SIGQUIT, gotsignal); siginterrupt(SIGQUIT, 0);
signal(SIGBUS, gotsignal); siginterrupt(SIGBUS, 0);
micrate(-1);
if(micratepresent()) {
    SLOT_S= 30;   // was 60 before 10.11.2011
  } else {
    SLOT_S= 5;   // in lab just 5secs
  };
/*
if(envcmp("VMESITE", "ALICE")==0) {
  udpsock= udpopens("alidcscom835", send2PORT);
} else {
  udpsock= udpopens("avmes", send2PORT);
}; */
ds_register();

while(1)  {  
  int rc=0;
  rc= update_qpll();
  if(rc!=0) break;
  //printf("sleteping 10secs...\n"); fflush(stdout);
  //sleep(1) ; 
  //msleep(1000);
  dtq_sleep(2);
  //printf("slept 10secs...\n"); fflush(stdout);
};  
ds_stop();
exit(0);
}   
开发者ID:AakaFosfor,项目名称:trigger,代码行数:34,代码来源:ttcmidims.c


示例6: install_signal_handlers

static void install_signal_handlers(void)
{
#ifdef SIGHUP
  /* ignore SIGHUP signal */
  if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
    logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
  /* ignore SIGPIPE signal */
  if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
    logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGINT
  /* handle SIGINT signal with our exit_signal_handler */
  if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
    logmsg("cannot install SIGINT handler: %s", strerror(errno));
  else
    siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
  /* handle SIGTERM signal with our exit_signal_handler */
  if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
    logmsg("cannot install SIGTERM handler: %s", strerror(errno));
  else
    siginterrupt(SIGTERM, 1);
#endif
#if defined(SIGBREAK) && defined(WIN32)
  /* handle SIGBREAK signal with our exit_signal_handler */
  if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR)
    logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
  else
    siginterrupt(SIGBREAK, 1);
#endif
}
开发者ID:MarcelRaad,项目名称:curl,代码行数:34,代码来源:tftpd.c


示例7: test_bye

test_code_t
test_bye (gnutls_session_t session)
{
  int ret;
  char data[20];
  int secs = 6;
#ifndef _WIN32
  int old;

  signal (SIGALRM, got_alarm);
#endif

  sprintf (prio_str, INIT_STR
           ALL_CIPHERS ":" ALL_COMP ":" ALL_CERTTYPES ":%s:" ALL_MACS ":"
           ALL_KX ":%s", protocol_str, rest);
  _gnutls_priority_set_direct (session, prio_str);

  gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);

  ret = do_handshake (session);
  if (ret == TEST_FAILED)
    return ret;

  ret = gnutls_bye (session, GNUTLS_SHUT_WR);
  if (ret < 0)
    return TEST_FAILED;

#ifndef _WIN32
  old = siginterrupt (SIGALRM, 1);
  alarm (secs);
#else
  setsockopt ((int) gnutls_transport_get_ptr (session), SOL_SOCKET,
              SO_RCVTIMEO, (char *) &secs, sizeof (int));
#endif

  do
    {
      ret = gnutls_record_recv (session, data, sizeof (data));
    }
  while (ret > 0);

#ifndef _WIN32
  siginterrupt (SIGALRM, old);
#else
  if (WSAGetLastError () == WSAETIMEDOUT ||
      WSAGetLastError () == WSAECONNABORTED)
    alrm = 1;
#endif
  if (ret == 0)
    return TEST_SUCCEED;

  if (alrm == 0)
    return TEST_UNSURE;

  return TEST_FAILED;
}
开发者ID:MihirKulkarni,项目名称:TLS_extension,代码行数:56,代码来源:tests.c


示例8: test_bye

test_code_t
test_bye (gnutls_session session)
{
  int ret;
  char data[20];
  int old, secs = 6;

#ifndef _WIN32
  signal (SIGALRM, got_alarm);
#endif

  ADD_ALL_CIPHERS (session);
  ADD_ALL_COMP (session);
  ADD_ALL_CERTTYPES (session);
  ADD_ALL_PROTOCOLS (session);
  ADD_ALL_MACS (session);
  ADD_ALL_KX (session);
  gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);

  ret = do_handshake (session);
  if (ret == TEST_FAILED)
    return ret;

  ret = gnutls_bye (session, GNUTLS_SHUT_WR);
  if (ret < 0)
    return TEST_FAILED;

#ifndef _WIN32
  old = siginterrupt (SIGALRM, 1);
  alarm (secs);
#else
  setsockopt (gnutls_transport_get_ptr (session), SOL_SOCKET, SO_RCVTIMEO,
	      (char *) &secs, sizeof (int));
#endif

  do
    {
      ret = gnutls_record_recv (session, data, sizeof (data));
    }
  while (ret > 0);

#ifndef _WIN32
  siginterrupt (SIGALRM, old);
#else
  if (WSAGetLastError () == WSAETIMEDOUT ||
      WSAGetLastError () == WSAECONNABORTED)
    alrm = 1;
#endif
  if (ret == 0)
    return TEST_SUCCEED;

  if (alrm == 0)
    return TEST_UNSURE;

  return TEST_FAILED;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:56,代码来源:tests.c


示例9: voice_install_signal_handler

int voice_install_signal_handler(void)
     {
     lprintf(L_NOISE, "%s: Installing signal handlers", program_name);

     if (signals_initialized)
          {
          lprintf(L_NOISE, "%s: Signal handlers are already installed",
           program_name);
          return(OK);
          };

     old_sigalrm = signal(SIGALRM, signal_sigalrm);
     old_sigchld = signal(SIGCHLD, signal_sigchld);
     old_sighup = signal(SIGHUP, signal_sighup);
     old_sigint = signal(SIGINT, signal_sigint);
     old_sigpipe = signal(SIGPIPE, signal_sigpipe);
     old_sigquit = signal(SIGQUIT, signal_sigquit);
     old_sigterm = signal(SIGTERM, signal_sigterm);
     old_sigusr1 = signal(SIGUSR1, signal_sigusr1);
     old_sigusr2 = signal(SIGUSR2, signal_sigusr2);
#ifdef HAVE_SIGINTERRUPT
     siginterrupt(SIGALRM, TRUE);
     siginterrupt(SIGCHLD, TRUE);
     siginterrupt(SIGHUP, TRUE);
     siginterrupt(SIGINT, TRUE);
     siginterrupt(SIGPIPE, TRUE);
     siginterrupt(SIGQUIT, TRUE);
     siginterrupt(SIGTERM, TRUE);
     siginterrupt(SIGUSR1, TRUE);
     siginterrupt(SIGUSR2, TRUE);
#endif
     alarm(cvd.watchdog_timeout.d.i);
     signals_initialized = TRUE;
     return(OK);
     }
开发者ID:Distrotech,项目名称:mgetty,代码行数:35,代码来源:signal.c


示例10: listen_for_hijackers

/**
 * Listen on listener socket
 *
 */
static int listen_for_hijackers ( struct hijack_listener *listener,
                                  const char *interface ) {
    int fd;
    pid_t child;
    int rc;

    logmsg ( LOG_INFO, "Listening on %s\n", listener->sun.sun_path );

    while ( ! signalled ) {
        /* Accept new connection, interruptibly */
        siginterrupt ( SIGINT, 1 );
        siginterrupt ( SIGHUP, 1 );
        fd = accept ( listener->fd, NULL, 0 );
        siginterrupt ( SIGINT, 0 );
        siginterrupt ( SIGHUP, 0 );
        if ( fd < 0 ) {
            if ( errno == EINTR ) {
                continue;
            } else {
                logmsg ( LOG_ERR, "accept failed: %s\n",
                         strerror ( errno ) );
                goto err;
            }
        }

        /* Fork child process */
        child = fork();
        if ( child < 0 ) {
            logmsg ( LOG_ERR, "fork failed: %s\n",
                     strerror ( errno ) );
            goto err;
        }
        if ( child == 0 ) {
            /* I am the child; run the hijacker */
            rc = run_hijacker ( interface, fd );
            close ( fd );
            exit ( rc );
        }

        close ( fd );
    }

    logmsg ( LOG_INFO, "Stopped listening on %s\n",
             listener->sun.sun_path );
    return 0;

err:
    if ( fd >= 0 )
        close ( fd );
    return -1;
}
开发者ID:B-Rich,项目名称:serialice,代码行数:55,代码来源:hijack.c


示例11: check_signal

void
check_signal()
    /* check if a signal has been received and handle it */
{

    /* we reinstall the signal handler functions here and not directly in the handlers,
     * as it is not supported on some systems (HP-UX) and makes fcron crash */

    if (sig_chld > 0) {
        wait_chld();
        sig_chld = 0;
#ifdef HAVE_SIGNAL
        (void)signal(SIGCHLD, sigchild_handler);
        siginterrupt(SIGCHLD, 0);
#endif
    }
    if (sig_conf > 0) {

        if (sig_conf == 1) {
            /* update configuration */
            synchronize_dir(".", 0);
            sig_conf = 0;
#ifdef HAVE_SIGNAL
            signal(SIGHUP, sighup_handler);
            siginterrupt(SIGHUP, 0);
#endif
        }
        else {
            /* reload all configuration */
            reload_all(".");
            sig_conf = 0;
#ifdef HAVE_SIGNAL
            signal(SIGUSR1, sigusr1_handler);
            siginterrupt(SIGUSR1, 0);
#endif
        }

    }
    if (sig_debug > 0) {
        print_schedule();
        debug_opt = (debug_opt > 0) ? 0 : 1;
        explain("debug_opt = %d", debug_opt);
        sig_debug = 0;
#ifdef HAVE_SIGNAL
        signal(SIGUSR2, sigusr2_handler);
        siginterrupt(SIGUSR2, 0);
#endif
    }

}
开发者ID:colmsjo,项目名称:batches,代码行数:50,代码来源:fcron.c


示例12: get_con

int get_con(char* servername, int port)
{
	struct hostent *h2;
	struct sockaddr_in sin;
	inrp_by_user = YEA;
	show_message("½¨Á¢Á¬ÏßÖÐ (Ctrl-C ÖжÏ) ...");
	if ((h2 = gethostbyname(servername)) == NULL)
		sin.sin_addr.s_addr = inet_addr(servername);
	else
		memcpy(&sin.sin_addr.s_addr, h2->h_addr, h2->h_length);
	sin.sin_family = AF_INET;
	if (!(a = socket(AF_INET, SOCK_STREAM, 0)))
		return -1;
	sin.sin_port = htons(port);
	signal(SIGALRM, (void *) interrupt_chk);
	siginterrupt(SIGINT, 1);
	alarm(1);
	if ((connect(a, (struct sockaddr *) & sin, sizeof(sin))))
	{
		signal(SIGALRM, SIG_IGN);
		return -1;
	}
	signal(SIGALRM, SIG_IGN);
	inrp_by_user = NA;
	write(0, " ", 1);
	show_message(NULL);
	return 1;
}
开发者ID:madoldman,项目名称:inankai_bbs,代码行数:28,代码来源:bbsgopher.c


示例13: signal

/*---------------------------------------------*/ void gotsignal(int signum) {
char msg[100];
// SIGUSR1:  // kill -s USR1 pid
signal(signum, gotsignal); siginterrupt(signum, 0);
sprintf(msg, "got signal:%d", signum); prtLog(msg);
if((signum==SIGUSR1) || (signum==SIGQUIT) ) {
  int np;
  np= getNAllPartitions();
  if(np!=0) {
    //quit=1; // wait till all partitions stopped
    //sprintf(msg, "Waiting for the stop of all partitions before exit");
    sprintf(msg, "Unsuccessful attempt to stop ctpproxy, %d partitions active", np);
    prtLog(msg);
    pq_send(mq_sendmsg,"quitignored");
  } else {
    quit=10;  // stop immediately (no partitions loaded)
  };
} else if((signum==SIGKILL) || (signum==SIGINT) ) {
    sprintf(msg, "SIGINT, immediate stop"); prtLog(msg);
  quit=11; // =9. stop immediately
};
#ifdef PQWAY
if(quit>9) {
  pq_send(mq_sendmsg,"quit");
};
#endif
}
开发者ID:juskoa,项目名称:trigger,代码行数:27,代码来源:main_ctp.c


示例14: MR_signal_should_restart

void
MR_signal_should_restart(int sig, MR_bool restart)
{
#if defined(MR_HAVE_SIGACTION)
    struct sigaction    act;

    if (sigaction(sig, NULL, &act) != 0) {
        MR_perror("error setting signal system call behaviour");
        exit(1);
    }

    if (restart) {
        act.sa_flags |= SA_RESTART;
    } else {
        act.sa_flags &= ~SA_RESTART;
    }

    if (sigaction(sig, &act, NULL) != 0) {
        MR_perror("error setting signal system call behaviour");
        exit(1);
    }
#elif defined(MR_HAVE_SIGINTERRUPT)
    if (siginterrupt(sig, !restart) != 0) {
        MR_perror("error setting signal system call behaviour");
        exit(1);
    }
#endif
}
开发者ID:htzh,项目名称:mercury,代码行数:28,代码来源:mercury_signal.c


示例15: joe_set_signal

/* wrapper to hide signal interface differrencies */
int joe_set_signal(int signum, sighandler_t handler)
{
	int retval;
#ifdef HAVE_SIGACTION
	struct sigaction sact;

	memset(&sact, 0, sizeof(sact));
	sact.sa_handler = handler;
#ifdef SA_INTERRUPT
	sact.sa_flags = SA_INTERRUPT;
#endif
	retval = sigaction(signum, &sact, NULL);
#elif defined(HAVE_SIGVEC)
	struct sigvec svec;

	memset(&svec, 0, sizeof(svec));
	svec.sv_handler = handler;
#ifdef HAVE_SV_INTERRUPT
	svec.sv_flags = SV_INTERRUPT;
#endif
	retval = sigvec(signum, &svec, NULL);
#else
	retval = (signal(signum, handler) != SIG_ERR) ? 0 : -1;
#ifdef HAVE_SIGINTERRUPT
	siginterrupt(signum, 1);
#endif
#endif
	return(retval);
}
开发者ID:lpereira,项目名称:joe-editor,代码行数:30,代码来源:utils.c


示例16: sig_install_timer

static void sig_install_timer(void)
{
#if !OS_TIMER
	signal(SIGALRM, sig_handle_timer);
	sig_timer_emu_init(TIMER_INTERVAL * clk_tck);
#else
	struct sigaction sa;
	struct itimerval it;

	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = sig_handle_timer;
#ifdef SA_RESTART
	sa.sa_flags = SA_RESTART;
#endif
	sigaction(SIGALRM, &sa, NULL);
#if !defined(SA_RESTART) && !defined(__DJGPP__)
	siginterrupt(SIGALRM, 0);
#endif

	it.it_value.tv_sec = TIMER_INTERVAL;
	it.it_value.tv_usec = 0;
#if defined(SA_RESTART) || defined(__DJGPP__)
	it.it_interval = it.it_value;
#else
	memset(&it.it_interval, 0, sizeof(it.it_interval));
#endif
	if (setitimer(ITIMER_REAL, &it, NULL)) pexit("setitimer");
#endif
}
开发者ID:ZenBench,项目名称:client,代码行数:29,代码来源:signals.c


示例17: sig_alarm

static RETSIGTYPE sig_alarm(int signo) {
  struct sigaction act;

  act.sa_handler = sig_alarm;
  sigemptyset(&act.sa_mask);
  act.sa_flags = 0;

#ifdef SA_INTERRUPT
  act.sa_flags |= SA_INTERRUPT;
#endif

  /* Install this handler for SIGALRM. */
  if (sigaction(SIGALRM, &act, NULL) < 0) {
    pr_log_pri(PR_LOG_WARNING,
      "unable to install SIGALRM handler via sigaction(2): %s",
      strerror(errno));
  }

#ifdef HAVE_SIGINTERRUPT
  if (siginterrupt(SIGALRM, 1) < 0) {
    pr_log_pri(PR_LOG_WARNING,
      "unable to allow SIGALRM to interrupt system calls: %s", strerror(errno));
  }
#endif

  recvd_signal_flags |= RECEIVED_SIG_ALRM;
  nalarms++;

  /* Reset the alarm */
  _total_time += _current_timeout;
  if (_current_timeout) {
    _alarmed_time = time(NULL);
    alarm(_current_timeout);
  }
}
开发者ID:netdna,项目名称:proftpd,代码行数:35,代码来源:timers.c


示例18: setup_signals

/** Register all necessary signal handlers. */
void setup_signals(void)
{
  struct sigaction act;

  act.sa_handler = SIG_IGN;
  act.sa_flags = 0;
  sigemptyset(&act.sa_mask);
  sigaddset(&act.sa_mask, SIGPIPE);
  sigaddset(&act.sa_mask, SIGALRM);
#ifdef  SIGWINCH
  sigaddset(&act.sa_mask, SIGWINCH);
  sigaction(SIGWINCH, &act, 0);
#endif
  sigaction(SIGPIPE, &act, 0);

  act.sa_handler = sigalrm_handler;
  sigaction(SIGALRM, &act, 0);

  signal_add(&sig_hup, sighup_callback, 0, SIGHUP);
  signal_add(&sig_int, sigint_callback, 0, SIGINT);
  signal_add(&sig_term, sigterm_callback, 0, SIGTERM);
  signal_add(&sig_chld, sigchld_callback, 0, SIGCHLD);

#ifdef HAVE_RESTARTABLE_SYSCALLS
  /*
   * At least on Apollo sr10.1 it seems continuing system calls
   * after signal is the default. The following 'siginterrupt'
   * should change that default to interrupting calls.
   */
  siginterrupt(SIGALRM, 1);
#endif
}
开发者ID:NX-Andro,项目名称:nefarious,代码行数:33,代码来源:ircd_signal.c


示例19: signal_handler

static void
signal_handler(int sig_num)
{
#ifdef WITH_THREAD
#ifdef WITH_PTH
	if (PyThread_get_thread_ident() != main_thread) {
		pth_raise(*(pth_t *) main_thread, sig_num);
		return;
	}
#endif
	/* See NOTES section above */
	if (getpid() == main_pid) {
#endif
		is_tripped++;
		Handlers[sig_num].tripped = 1;
		Py_AddPendingCall(checksignals_witharg, NULL);
#ifdef WITH_THREAD
	}
#endif
#ifdef SIGCHLD
	if (sig_num == SIGCHLD) {
		/* To avoid infinite recursion, this signal remains
		   reset until explicit re-instated.
		   Don't clear the 'func' field as it is our pointer
		   to the Python handler... */
		return;
	}
#endif
#ifdef HAVE_SIGINTERRUPT
	siginterrupt(sig_num, 1);
#endif
	PyOS_setsig(sig_num, signal_handler);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:33,代码来源:signalmodule.c


示例20: main

int main (int argc, char *argv[])  {
  char c;
  printf("Tapez return en moins de 5 secondes ! \n");
  fflush(stdout);
  if(signal(SIGALRM,sig_handler)==SIG_ERR) {
    perror("signal");
    exit(EXIT_FAILURE);
  }
  // sigalrm interrompt les appels système
  if(siginterrupt(SIGALRM,true)<0) {
    perror("siginterrupt");
    exit(EXIT_FAILURE);
  }
  int r=0;
  alarm(5);
  if(!expired) {
    r=read(STDIN_FILENO,&c,1);
  }
  else {
    // sig_handler a déjà été exécuté
    // le délai a déjà expiré, inutile de faire read
  }
  alarm(0); // arrêt du timer
  if((r==1)&&(c=='\n')) {
    printf("Gagné \n");
    exit(EXIT_SUCCESS);
  }
  else {
    printf("Perdu !\n");
    exit(EXIT_FAILURE);
  }
}
开发者ID:BaptisteDegryse,项目名称:SystemesInformatiques,代码行数:32,代码来源:alarm3.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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