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

C++ sigtimedwait函数代码示例

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

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



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

示例1: vlc_write

ssize_t vlc_write(int fd, const void *buf, size_t len)
{
    struct iovec iov = { .iov_base = (void *)buf, .iov_len = len };

    return vlc_writev(fd, &iov, 1);
}

ssize_t vlc_writev(int fd, const struct iovec *iov, int count)
{
    sigset_t set, oset;

    sigemptyset(&set);
    sigaddset(&set, SIGPIPE);
    pthread_sigmask(SIG_BLOCK, &set, &oset);

    ssize_t val = writev(fd, iov, count);
    if (val < 0 && errno == EPIPE)
    {
        siginfo_t info;
        struct timespec ts = { 0, 0 };

        while (sigtimedwait(&set, &info, &ts) >= 0 || errno != EAGAIN);
    }

    if (!sigismember(&oset, SIGPIPE)) /* Restore the signal mask if changed */
        pthread_sigmask(SIG_SETMASK, &oset, NULL);

    return val;
}
开发者ID:RamboLouis,项目名称:vlc,代码行数:29,代码来源:filesystem.c


示例2: main

int main() {
  int signum=SIGRTMIN+1;
  sigset_t ss;
  sigemptyset(&ss);
  sigaddset(&ss,signum);
  sigaddset(&ss,SIGIO);
  sigprocmask(SIG_BLOCK,&ss,0);

  fcntl(0 /* fd */,F_SETOWN,getpid());
  fcntl(0 /* fd */,F_SETSIG,signum);
#if defined(O_ONESIGFD) && defined(F_SETAUXFL)
  fcntl(0 /* fd */, F_SETAUXFL, O_ONESIGFD);
#endif
  fcntl(0 /* fd */,F_SETFL,fcntl(0 /* fd */,F_GETFL)|O_NONBLOCK|O_ASYNC);

  {
    siginfo_t info;
    struct timespec timeout;
    int r;
    timeout.tv_sec=1; timeout.tv_nsec=0;
    switch ((r=sigtimedwait(&ss,&info,&timeout))) {
    case SIGIO:
      /* signal queue overflow */
      signal(signum,SIG_DFL);
      /* do poll */
      break;
    default:
      if (r==signum) {
	printf("event %c%c on fd #%d\n",info.si_band&POLLIN?'r':'-',info.si_band&POLLOUT?'w':'-',info.si_fd);
      }
    }
  }
  return 0;
}
开发者ID:djbtao,项目名称:libowfat,代码行数:34,代码来源:trysigio.c


示例3: sigemptyset

// Отправка пакета адресату.
bool NetHub::SendToAddress(ConnectionData &oConnectionData, bool bResetPointer)
{
    int iLength;
#ifndef WIN32
    sigset_t ssOldset, ssNewset;
    siginfo_t sI;
    struct timespec tsTime = {0, 0};
    sigset_t* p_ssNewset;
    //
    p_ssNewset = &ssNewset;
    sigemptyset(&ssNewset);
    sigaddset(&ssNewset, SIGPIPE);
    pthread_sigmask(SIG_BLOCK, &ssNewset, &ssOldset);
    iLength = (int)(p_chPocketsBufferPositionPointer - m_chPocketsBuffer);
    oConnectionData.iStatus = (int)send(oConnectionData.iSocket, (void*)m_chPocketsBuffer, (size_t)iLength, 0);
#else
    iLength = (int)(p_chPocketsBufferPositionPointer - m_chPocketsBuffer);
    oConnectionData.iStatus = send(oConnectionData.iSocket,
                                   (const char*)m_chPocketsBuffer, (size_t)iLength, 0);
#endif
#ifndef WIN32
    while(sigtimedwait(p_ssNewset, &sI, &tsTime) >= 0 || errno != EAGAIN);
    pthread_sigmask(SIG_SETMASK, &ssOldset, nullptr);
#endif
    if(bResetPointer) ResetPocketsBufferPositionPointer();
    if(oConnectionData.iStatus == -1)
    {
        return false;
    }
    return true;
}
开发者ID:Intueor,项目名称:Z-Server,代码行数:32,代码来源:net-hub.cpp


示例4: waittermsig

static void waittermsig(int sig, const char* waiter) {
  struct timespec ts = {.tv_sec = 1 };
  sigset_t set;
  siginfo_t si;

  sigemptyset(&set);
  sigaddset(&set, sig);
  sigtimedwait(&set, &si, &ts);

  atomic_printf("FAILED: %s: signal %d either not caught or didn't terminate "
                "process within 1 second\n",
                waiter, sig);
}

static void* kill_thread(void* dontcare) {
  const int termsig = SIGTERM;

  atomic_puts("killing...");
  kill(getpid(), termsig);
  waittermsig(termsig, "kill_thread");
  return NULL; /* not reached */
}

int main(int argc, char* argv[]) {
  pthread_t t;

  pthread_create(&t, NULL, kill_thread, NULL);
  pthread_join(t, NULL);
  atomic_puts("FAILED: joined thread that should have died");
  return 0;
}
开发者ID:szborows,项目名称:rr,代码行数:31,代码来源:term_nonmain.c


示例5: sigwaiter

/*
 * Another thread body for the pthread_kill + sigwait tests.
 */
void *
sigwaiter(void *arg)
{
	int			rval;
	siginfo_t		info;
	sigset_t		set;
	oskit_timespec_t	timeout = { 1, 0 };
	
	pthread_cleanup_push(cleaner, arg);

	sigemptyset(&set);
	sigaddset(&set, SIGUSR1);
	pthread_sigmask(SIG_BLOCK, &set, 0);
	
	printf("sigwaiter:%d ready\n", (int) pthread_self());
	
	while (1) {
		memset(&info, 0, sizeof(info));
		
		if ((rval = sigtimedwait(&set, &info, &timeout)) != 0)
			oskit_error(rval, "sigwaiter");
				    
		printf("sigwaiter:%d rval:0x%x sig:%d code:%d val:%d\n",
		       (int) pthread_self(), rval,
		       info.si_signo, info.si_code, info.si_value.sival_int);

		oskit_pthread_sleep(20);
	}

	pthread_cleanup_pop(1);
	return 0;
}
开发者ID:dzavalishin,项目名称:oskit,代码行数:35,代码来源:sigtest.c


示例6: sigsuspend

int sigsuspend(
  const sigset_t  *sigmask
)
{
  sigset_t            saved_signals_blocked;
  sigset_t            current_unblocked_signals;
  int                 status;
  POSIX_API_Control  *api;

  api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];

  /*
   *  We use SIG_BLOCK and not SIG_SETMASK because there may be
   *  signals which might be pending, which might get caught here.
   *  We want the signals to be caught inside sigtimedwait.
   */
  status = sigprocmask( SIG_BLOCK, sigmask, &saved_signals_blocked );

  current_unblocked_signals = ~(*sigmask);
  status = sigtimedwait( &current_unblocked_signals, NULL, NULL );

  (void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL );

  /*
   * sigtimedwait() returns the signal number while sigsuspend()
   * is supposed to return -1 and EINTR when a signal is caught.
   */
  #if defined(RTEMS_DEBUG)
    assert( status != -1 );
  #endif

  rtems_set_errno_and_return_minus_one( EINTR );
}
开发者ID:0871087123,项目名称:rtems,代码行数:33,代码来源:sigsuspend.c


示例7: sigwaitinfo

int sigwaitinfo(
  const sigset_t  *set,
  siginfo_t       *info
)
{
  return sigtimedwait( set, info, NULL );
}
开发者ID:epicsdeb,项目名称:rtems,代码行数:7,代码来源:sigwaitinfo.c


示例8: main

int main (void)
{
	sigset_t         ensemble;
	int              numero;
	struct timespec  delai;

	fprintf(stderr, "PID=%ld\n", (long) getpid());

	/* Blocage de tous les signaux */
	sigfillset(& ensemble);
	sigprocmask(SIG_BLOCK, & ensemble, NULL);

	/* Attente de tous les signaux pendant 10 secondes */
	delai.tv_sec = 10;
	delai.tv_nsec = 0;
	sigfillset(& ensemble);

	while (1) {
		if ((numero = sigtimedwait(& ensemble, NULL, & delai)) < 0) {
			perror("sigtimedwait");
			break;
		}
		fprintf(stderr, "sigtimedwait : %d recu \n", numero);
	}
	return EXIT_SUCCESS;
}
开发者ID:cpb-,项目名称:Developpement-systeme-sous-Linux,代码行数:26,代码来源:exemple-sigtimedwait.c


示例9: main

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

    int result = 0;

    sigset_t waitset;
    siginfo_t info;
    struct timespec timeout;

    sigemptyset( &waitset );
    sigaddset( &waitset, SIGALRM );

    sigprocmask( SIG_BLOCK, &waitset, NULL );
    timeout.tv_sec = 5;     /* Number of seconds to wait */
    timeout.tv_nsec = 1000;  /* Number of nanoseconds to wait */


    alarm(5);

    timestamp( "before sigtimedwait()" );

    result = sigtimedwait( &waitset, &info, &timeout );
    if( result <  0 ) {
	printf("sigtimedwait failed : \n");
        exit(1);
    }

    printf( "sigtimedwait returned for signal %d\n",info.si_signo );

    timestamp( "after sigtimedwait()" );

    return( result );
}
开发者ID:md-jamal,项目名称:Linuxpro,代码行数:32,代码来源:sigwait2.c


示例10: time_cron

void *
time_cron(void *arg)
{
    struct server *s = (struct server *) arg;
    struct timespec tv = { 0 };
    sigset_t waitset;
    siginfo_t info;
    int ret;
    sigemptyset(&waitset);
    sigaddset(&waitset, SIGUSR1);
//     pthread_mutex_init(&gnlock, NULL);
    global_now = time(NULL);
    while (1) {
        tv.tv_sec = 1;
        tv.tv_nsec = 0;
        ret = sigtimedwait(&waitset, &info, &tv);
        if (ret > 0)
            s->refreshflag = 1;
//         pthread_mutex_lock(&gnlock);
//         global_now++;
//         pthread_mutex_unlock(&gnlock);
        //printf("time %lu\n",global_now);
//         if ((global_now % 100) == 0) {
//             pthread_mutex_lock(&gnlock);
            global_now = time(NULL);
//             pthread_mutex_unlock(&gnlock);
//         }
    }
    return NULL;
}
开发者ID:BearGrass,项目名称:dnspod-sr,代码行数:30,代码来源:init.c


示例11: run_sigtimedwait

int run_sigtimedwait(sigwait_params_t *params)
{
  int ret = sigtimedwait(&params->waitset, &params->info, &params->timeout);

  if (-1 == ret && EAGAIN == errno) return 1;

  return 0;
}
开发者ID:swift-nav,项目名称:piksi_buildroot,代码行数:8,代码来源:util.c


示例12: sigwait

int sigwait(const sigset_t *mask, int *sig)
{
	siginfo_t si;
	if (sigtimedwait(mask, &si, NULL) < 0)
		return -1;
	*sig = si.si_signo;
	return 0;
}
开发者ID:GregorR,项目名称:musl,代码行数:8,代码来源:sigwait.c


示例13: do_test

static void do_test(int i)
{
	pid_t cpid;

	cpid = tst_fork();
	if (cpid < 0)
		tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");

	if (cpid == 0)
		do_child(i);

	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);

	TEST(fcntl(fd, F_SETLEASE, test_cases[i].lease_type));
	if (TEST_RETURN == -1) {
		tst_resm(TFAIL | TTERRNO, "fcntl() failed to set lease");
		SAFE_WAITPID(cleanup, cpid, NULL, 0);
		SAFE_CLOSE(cleanup, fd);
		fd = 0;
		return;
	}

	/* Wait for SIGIO caused by lease breaker. */
	TEST(sigtimedwait(&newset, NULL, &timeout));
	if (TEST_RETURN == -1) {
		if (TEST_ERRNO == EAGAIN) {
			tst_resm(TFAIL | TTERRNO, "failed to receive SIGIO "
				 "within %lis", timeout.tv_sec);
			SAFE_WAITPID(cleanup, cpid, NULL, 0);
			SAFE_CLOSE(cleanup, fd);
			fd = 0;
			return;
		}
		tst_brkm(TBROK | TTERRNO, cleanup, "sigtimedwait() failed");
	}

	/* Try to downgrade or remove the lease. */
	switch (test_cases[i].lease_type) {
	case F_WRLCK:
		TEST(fcntl(fd, F_SETLEASE, F_RDLCK));
		if (TEST_RETURN == 0)
			break;
	case F_RDLCK:
		TEST(fcntl(fd, F_SETLEASE, F_UNLCK));
		if (TEST_RETURN == -1) {
			tst_resm(TFAIL | TTERRNO,
				 "fcntl() failed to remove the lease");
		}
		break;
	default:
		break;
	}

	tst_record_childstatus(cleanup, cpid);

	SAFE_CLOSE(cleanup, fd);
	fd = 0;
}
开发者ID:CSRedRat,项目名称:ltp,代码行数:58,代码来源:fcntl33.c


示例14: thf_sighandler

/*
 * Signal handler.
 *
 * This thread is reponsible for allowing switches between the
 * silent and verbose ttys, and for cleanup tasks after reception
 * of SIGTERM.
 */
void* thf_sighandler(void *unusued)
{
	sigset_t sigset, sigset_switch;
	int sig;

	/* We don't handle SIGALRM. */
	sigemptyset(&sigset);
	sigaddset(&sigset, SIGALRM);
	pthread_sigmask(SIG_BLOCK, &sigset, NULL);

	sigemptyset(&sigset);
	sigaddset(&sigset, SIGUSR1);
	sigaddset(&sigset, SIGUSR2);
	sigaddset(&sigset, SIGTERM);
	sigaddset(&sigset, SIGINT);

	sigemptyset(&sigset_switch);
	sigaddset(&sigset_switch, SIGUSR1);
	sigaddset(&sigset_switch, SIGUSR2);

	while (1) {
		sigwait(&sigset, &sig);

		process_switch_sig(sig);

		/* Internally generated terminate signal */
		if (sig == SIGINT) {
			struct timespec timeout;
			timeout.tv_sec = 0;
			timeout.tv_nsec = 0;
			bool pending = true;

			/*
			 * Process any remaining signals.  There are no guarantees as to the
			 * order in which the signals are delivered, so we have to make sure
			 * all pending signals are processed before exiting.
			 */
			while (pending) {
				sig = sigtimedwait(&sigset_switch, NULL, &timeout);

				if (sig == -1) {
					/* No more pending signals. */
					if (errno == EAGAIN)
						pending = false;
				} else {
					process_switch_sig(sig);
				}
			}

			do_cleanup();
			pthread_exit(NULL);
		} else if (sig == SIGTERM) {
			do_cleanup();
			exit(0);
		}
	}
}
开发者ID:kissthink,项目名称:fbsplash,代码行数:64,代码来源:daemon.c


示例15: main

int main(int argc, char *argv[]) {
	struct server server;
	sigset_t sigset;
	siginfo_t siginfo;
	struct timespec tmo;

	{ // setup server
		server.server_socket.addr = INADDR_ANY;
		server.server_socket.port = 8000;
		server.nrequest_max = 1024;
		server.nworker_min = 16;
		server.nworker_max = 32;
		server.nevent = 10;
		server.event_tmo = 10;
		if (server_init(&server)) {
			perror("server_init");
			return -1;
		}
	}
	{ // blocking all signals
		sigfillset(&sigset);
		if (pthread_sigmask(SIG_BLOCK, &sigset, NULL) != 0) {
			perror("pthread_sigmask");
			return -1;
		}
	}
	server_startup(&server);
	{ // signal handling
		tmo.tv_sec = 0;
		tmo.tv_nsec = 100000000; // 100 ms
		sigemptyset(&sigset);
		sigaddset(&sigset, SIGINT);
		sigfillset(&sigset);
		do {
			int signo = sigtimedwait(&sigset, &siginfo, &tmo);
			//int signo = sigwaitinfo(&sigset, &siginfo);
			if (signo == -1) {
				if (errno == EAGAIN || errno == EINTR) {
					continue;
				}
				perror("sigwaitinfo");
				break;
			}
			//dispatch_signal(siginfo);
			printf("got signal %d\n", siginfo.si_signo);
			if (siginfo.si_signo == SIGINT) {
				printf("interrupted, quittingx\n");
				break;
			}
		} while (1);
	}

	printf("shuting down\n");
	server_shutdown(&server);

	return 0;
}
开发者ID:oxnz,项目名称:RTFSC,代码行数:57,代码来源:main.c


示例16: wait_child

static int
wait_child(pid_t pid, int* status, int ms)
{
    sigset_t set, oldset;
    struct sigaction act, oldact;
    struct timespec timeout;
    int ret = 0;

    /* Block SIGCHLD */
    sigemptyset(&set);
    sigaddset(&set, SIGCHLD);
    sigprocmask(SIG_BLOCK, &set, &oldset);
    /* Register handler for SIGCHLD to ensure
       it is processed */
    act.sa_handler = sigchld_handler;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    sigaction(SIGCHLD, &act, &oldact);
    
    /* Check if the child already exited before
       we blocked the signal */
    if (waitpid(pid, status, WNOHANG) == pid)
    {
        /* It did, so we are done */
        ret = 0;
        goto done;
    }
    
    timeout.tv_sec = ms / 1000;
    timeout.tv_nsec = (ms % 1000) * 1000000;
    /* Otherwise, wait for it to exit with a timeout */
    sigtimedwait(&set, NULL, &timeout);
    
    /* Check one more time for status */
    if (waitpid(pid, status, WNOHANG) == pid)
    {
        /* It finally exited */
        ret = 0;
        goto done;
    }
    else
    {
        /* Kill the thing and wait once more to reap
           the zombie process */
        kill(pid, SIGKILL);
        waitpid(pid, NULL, 0);
        ret = -1;
        goto done;
    }

done:
    /* Finally, restore old signal handler/signal masks */
    sigprocmask(SIG_SETMASK, &oldset, NULL);
    sigaction(SIGCHLD, &oldact, NULL);

    return ret;
}
开发者ID:markjdb,项目名称:moonunit,代码行数:57,代码来源:c-run.c


示例17: fdevent_linux_rtsig_poll

static int fdevent_linux_rtsig_poll(fdevents * ev, int timeout_ms)
{
	struct timespec ts;
	int r;

#if 0
	fdevent_linux_rtsig_event_compress(ev);
#endif

	ev->in_sigio = 1;

	ts.tv_sec = timeout_ms / 1000;
	ts.tv_nsec = (timeout_ms % 1000) * 1000000;
	r = sigtimedwait(&(ev->sigset), &(ev->siginfo), &(ts));

	if (r == -1)
	{
		if (errno == EAGAIN)
			return 0;
		return r;
	} else if (r == SIGIO)
	{
		struct sigaction act;

		/*
		 * flush the signal queue 
		 */
		memset(&act, 0, sizeof(act));
		act.sa_handler = SIG_IGN;
		sigaction(ev->signum, &act, NULL);

		/*
		 * re-enable the signal queue 
		 */
		act.sa_handler = SIG_DFL;
		sigaction(ev->signum, &act, NULL);

		ev->in_sigio = 0;
		r = poll(ev->pollfds, ev->used, timeout_ms);

		return r;
	} else if (r == ev->signum)
	{
#  if 0
		fprintf(stderr, "event: %d %02lx\n", ev->siginfo.si_fd,
				ev->siginfo.si_band);
#  endif
		return bitset_test_bit(ev->sigbset, ev->siginfo.si_fd);
	} else
	{
		/*
		 * ? 
		 */
		return -1;
	}
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:56,代码来源:fdevent_linux_rtsig.c


示例18: main

int main(int argc, char *argv[]) {
	struct vme_sg_simple_time ttime, ttime2;
	int ttfd;		/* File descriptor for the TrueTime device */
	int i;
	int signo;

	setpriority(PRIO_PROCESS, (0), 100);
	if((ttfd = open("/dev/vme_sg_simple", O_RDWR, 0)) < 0) {
	    perror("Can't open TrueTIme");
	    exit(-1);
	}
    timeout.tv_sec = 0;
    timeout.tv_nsec = 10000000;
    sigemptyset(&sigs);
    sigaddset(&sigs, SIGINT);
    for(i = 0; i < 10; i++) {
#if 1
	if(read(ttfd, &ttime, sizeof(ttime)) < 0) {
	    perror("Trouble reading the truetime");
	    return(-1);
	}
#endif
#if TESTSIGTIMEDWAIT
	if((signo = sigtimedwait(&sigs, &extra, &timeout)) < 0) {
	    switch(errno) {
	    case EAGAIN:
		break;
	    case EINTR:
		printf("Received SIGINT\n");
		exit(0);
	    case EINVAL:
		printf("invalid tv_nsec = %d\n", (int)timeout.tv_nsec);
		exit(1);
	    }
	} else {
	    printf("Signal %d arrived\n", signo);
	    exit(0);
	}
#if 1
	if(read(ttfd, &ttime2, sizeof(ttime2)) < 0) {
	    perror("Trouble reading the truetime");
	    return(-1);
	}
	printf("usec before %6d, after %6d\n", ttime.usec, ttime2.usec);
	for(signo = 0; signo < 240000; signo++) {
	    
	}
#endif
#else
	printf("day = %d %d:%d:%d.%06d\n", ttime.yday, ttime.hour,
		ttime.min, ttime.sec, ttime.usec);
	usleep(10000);
#endif
    }
	return(0);
}
开发者ID:nimeshpatel,项目名称:smaSoftware,代码行数:56,代码来源:ttread.test_sigtimedwait.c


示例19: newOmega

        void *alpha_func(void *p)
        {
            omg1 = newOmega();
            omg2 = newOmega();
            omg3 = newOmega();

            sigset_t ss;
            siginfo_t siginfo;
            int signum;

            sigemptyset(&ss);
            if (sigaddset(&ss, SIGUSR1) != 0) {
                return NULL;
            }
            if (sigprocmask(SIG_BLOCK, &ss, NULL)) {
                return NULL;
            }

            struct timespec interval;
            interval.tv_sec = 0;
            interval.tv_nsec = 500000000;

            pid_t pid = getpid();
            printf("pid = %d\n", pid);

            while (1) {
                signum = sigtimedwait(&ss, &siginfo, &interval);
                if (signum >= 0) {
                    switch (signum) {
                        case SIGUSR1:
                            puts("GET END SIGNAL");
                            return NULL;
                        default:
                            break;
                    }
                } else if (signum == -1) {
                    //printf("sigerrno = %d\n", siginfo.si_errno);
                    if (errno == EAGAIN) {
                        puts("Could not catch any signal in signal set while timeout.");
                        continue;
                    }
                    if (errno == EINTR) {
                        perror("Sigwait interrupted by another signal handler.");
                        continue;
                    }
                    if (errno == EINVAL) {
                        perror("Timeout value is invalid.");
                        return NULL;
                    }
                } else {
                    perror("Unknown Error in alpha function.");
                    return NULL;
                }
            }
            return NULL;
        }
开发者ID:CanisFramework,项目名称:Canis,代码行数:56,代码来源:alpha.cpp


示例20: sigemptyset

void
xt::Process::WaitForSignal(int signal, int timeout)
{
  sigset_t signalMask;
  
  if (timeout >= 0)
  {
    static const uint32_t MsecToNsec = 1000000;
    static const uint32_t SecToMsec = 1000;
    int seconds = timeout / SecToMsec;
    
    /* Remove seconds from timeout */
    timeout -= seconds * SecToMsec;
    struct timespec ts = { seconds, timeout * MsecToNsec };
    
    sigemptyset(&signalMask);
    sigaddset(&signalMask, signal);
    int received = 0;
    
    do
    {
      errno = 0;
      received = sigtimedwait(&signalMask,
                              NULL,
                              &ts);
      if (received == -1)
      {
        /* Just retry if we got signalled */
        if (errno != EINTR)
        {
          std::stringstream ss;
          ss << "sigtimedwait: "
             << strerror(errno);

          throw std::runtime_error(ss.str());
        }
      }
    } while (errno != 0);
    
    return;
  }
  else
  {
    sigemptyset(&signalMask);
    sigaddset(&signalMask, signal);
    errno = 0;
    int received = sigwaitinfo(&signalMask, NULL);
    
    if (received != signal)
    {
      std::stringstream ss;
      ss << "sigwaitinfo: "
         << strerror(errno);
    }
  }
}
开发者ID:krnlyng,项目名称:xbmc,代码行数:56,代码来源:WestonProcess.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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