本文整理汇总了C++中sigismember函数的典型用法代码示例。如果您正苦于以下问题:C++ sigismember函数的具体用法?C++ sigismember怎么用?C++ sigismember使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sigismember函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ERR_PTR
//.........这里部分代码省略.........
/* ok, now we should be set up.. */
p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL);
p->pdeath_signal = 0;
p->exit_state = 0;
/* Perform scheduler related setup */
sched_fork(p);
/*
* Ok, make it visible to the rest of the system.
* We dont wake it up yet.
*/
p->group_leader = p;
INIT_LIST_HEAD(&p->ptrace_children);
INIT_LIST_HEAD(&p->ptrace_list);
/* Need tasklist lock for parent etc handling! */
write_lock_irq(&tasklist_lock);
/*
* The task hasn't been attached yet, so cpus_allowed mask cannot
* have changed. The cpus_allowed mask of the parent may have
* changed after it was copied first time, and it may then move to
* another CPU - so we re-copy it here and set the child's CPU to
* the parent's CPU. This avoids alot of nasty races.
*/
p->cpus_allowed = current->cpus_allowed;
set_task_cpu(p, smp_processor_id());
/*
* Check for pending SIGKILL! The new thread should not be allowed
* to slip out of an OOM kill. (or normal SIGKILL.)
*/
if (sigismember(¤t->pending.signal, SIGKILL)) {
write_unlock_irq(&tasklist_lock);
retval = -EINTR;
goto bad_fork_cleanup_namespace;
}
/* CLONE_PARENT re-uses the old parent */
if (clone_flags & (CLONE_PARENT|CLONE_THREAD))
p->real_parent = current->real_parent;
else
p->real_parent = current;
p->parent = p->real_parent;
if (clone_flags & CLONE_THREAD) {
spin_lock(¤t->sighand->siglock);
/*
* Important: if an exit-all has been started then
* do not create this new thread - the whole thread
* group is supposed to exit anyway.
*/
if (current->signal->flags & SIGNAL_GROUP_EXIT) {
spin_unlock(¤t->sighand->siglock);
write_unlock_irq(&tasklist_lock);
retval = -EAGAIN;
goto bad_fork_cleanup_namespace;
}
p->group_leader = current->group_leader;
if (current->signal->group_stop_count > 0) {
/*
* There is an all-stop in progress for the group.
* We ourselves will stop as soon as we check signals.
* Make the new thread part of that group stop too.
开发者ID:Pating,项目名称:linux-2.6.12-rc2,代码行数:67,代码来源:fork.c
示例2: tstp
static void
tstp(int dummy GCC_UNUSED)
{
sigset_t mask, omask;
sigaction_t act, oact;
#ifdef SIGTTOU
int sigttou_blocked;
#endif
T(("tstp() called"));
/*
* The user may have changed the prog_mode tty bits, so save them.
*
* But first try to detect whether we still are in the foreground
* process group - if not, an interactive shell may already have
* taken ownership of the tty and modified the settings when our
* parent was stopped before us, and we would likely pick up the
* settings already modified by the shell.
*/
if (SP != 0 && !SP->_endwin) /* don't do this if we're not in curses */
#if HAVE_TCGETPGRP
if (tcgetpgrp(STDIN_FILENO) == getpgrp())
#endif
def_prog_mode();
/*
* Block window change and timer signals. The latter
* is because applications use timers to decide when
* to repaint the screen.
*/
(void) sigemptyset(&mask);
(void) sigaddset(&mask, SIGALRM);
#if USE_SIGWINCH
(void) sigaddset(&mask, SIGWINCH);
#endif
(void) sigprocmask(SIG_BLOCK, &mask, &omask);
#ifdef SIGTTOU
sigttou_blocked = sigismember(&omask, SIGTTOU);
if (!sigttou_blocked) {
(void) sigemptyset(&mask);
(void) sigaddset(&mask, SIGTTOU);
(void) sigprocmask(SIG_BLOCK, &mask, NULL);
}
#endif
/*
* End window mode, which also resets the terminal state to the
* original (pre-curses) modes.
*/
endwin();
/* Unblock SIGTSTP. */
(void) sigemptyset(&mask);
(void) sigaddset(&mask, SIGTSTP);
#ifdef SIGTTOU
if (!sigttou_blocked) {
/* Unblock this too if it wasn't blocked on entry */
(void) sigaddset(&mask, SIGTTOU);
}
#endif
(void) sigprocmask(SIG_UNBLOCK, &mask, NULL);
/* Now we want to resend SIGSTP to this process and suspend it */
act.sa_handler = SIG_DFL;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
sigaction(SIGTSTP, &act, &oact);
kill(getpid(), SIGTSTP);
/* Process gets suspended...time passes...process resumes */
T(("SIGCONT received"));
sigaction(SIGTSTP, &oact, NULL);
flushinp();
/*
* If the user modified the tty state while suspended, he wants
* those changes to stick. So save the new "default" terminal state.
*/
def_shell_mode();
/*
* This relies on the fact that doupdate() will restore the
* program-mode tty state, and issue enter_ca_mode if need be.
*/
doupdate();
/* Reset the signals. */
(void) sigprocmask(SIG_SETMASK, &omask, NULL);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:96,代码来源:lib_tstp.c
示例3: pth_sched_eventmanager
/*
* Look whether some events already occurred (or failed) and move
* corresponding threads from waiting queue back to ready queue.
*/
intern void pth_sched_eventmanager(pth_time_t *now, int dopoll)
{
pth_t nexttimer_thread;
pth_event_t nexttimer_ev;
pth_time_t nexttimer_value;
pth_event_t evh;
pth_event_t ev;
pth_t t;
pth_t tlast;
int this_occurred;
int any_occurred;
fd_set rfds;
fd_set wfds;
fd_set efds;
struct timeval delay;
struct timeval *pdelay;
sigset_t oss;
struct sigaction sa;
struct sigaction osa[1+PTH_NSIG];
char minibuf[128];
int loop_repeat;
int fdmax;
int rc;
int sig;
int n;
pth_debug2("pth_sched_eventmanager: enter in %s mode",
dopoll ? "polling" : "waiting");
/* entry point for internal looping in event handling */
loop_entry:
loop_repeat = FALSE;
/* initialize fd sets */
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&efds);
fdmax = -1;
/* initialize signal status */
sigpending(&pth_sigpending);
sigfillset(&pth_sigblock);
sigemptyset(&pth_sigcatch);
sigemptyset(&pth_sigraised);
/* initialize next timer */
pth_time_set(&nexttimer_value, PTH_TIME_ZERO);
nexttimer_thread = NULL;
nexttimer_ev = NULL;
/* for all threads in the waiting queue... */
any_occurred = FALSE;
for (t = pth_pqueue_head(&pth_WQ); t != NULL;
t = pth_pqueue_walk(&pth_WQ, t, PTH_WALK_NEXT)) {
/* determine signals we block */
for (sig = 1; sig < PTH_NSIG; sig++)
if (!sigismember(&(t->mctx.sigs), sig))
sigdelset(&pth_sigblock, sig);
/* cancellation support */
if (t->cancelreq == TRUE)
any_occurred = TRUE;
/* ... and all their events... */
if (t->events == NULL)
continue;
/* ...check whether events occurred */
ev = evh = t->events;
do {
if (ev->ev_status == PTH_STATUS_PENDING) {
this_occurred = FALSE;
/* Filedescriptor I/O */
if (ev->ev_type == PTH_EVENT_FD) {
/* filedescriptors are checked later all at once.
Here we only assemble them in the fd sets */
if (ev->ev_goal & PTH_UNTIL_FD_READABLE)
FD_SET(ev->ev_args.FD.fd, &rfds);
if (ev->ev_goal & PTH_UNTIL_FD_WRITEABLE)
FD_SET(ev->ev_args.FD.fd, &wfds);
if (ev->ev_goal & PTH_UNTIL_FD_EXCEPTION)
FD_SET(ev->ev_args.FD.fd, &efds);
if (fdmax < ev->ev_args.FD.fd)
fdmax = ev->ev_args.FD.fd;
}
/* Filedescriptor Set Select I/O */
else if (ev->ev_type == PTH_EVENT_SELECT) {
/* filedescriptors are checked later all at once.
Here we only merge the fd sets. */
pth_util_fds_merge(ev->ev_args.SELECT.nfd,
ev->ev_args.SELECT.rfds, &rfds,
ev->ev_args.SELECT.wfds, &wfds,
ev->ev_args.SELECT.efds, &efds);
if (fdmax < ev->ev_args.SELECT.nfd-1)
fdmax = ev->ev_args.SELECT.nfd-1;
//.........这里部分代码省略.........
开发者ID:sushengloong,项目名称:comp3301-s4239799,代码行数:101,代码来源:pth_sched.c
示例4: softsig_thread
static void *
softsig_thread(void *arg)
{
sigset_t ss, os;
int i;
sigemptyset(&ss);
/* get the list of signals _not_ blocked by AFS_SIGSET_CLEAR() */
pthread_sigmask(SIG_BLOCK, &ss, &os);
pthread_sigmask(SIG_SETMASK, &os, NULL);
sigaddset(&ss, SIGUSR1);
#if defined(AFS_DARWIN_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
pthread_sigmask (SIG_BLOCK, &ss, NULL);
sigdelset (&os, SIGUSR1);
#elif !defined(AFS_HPUX_ENV)
/* On HPUX, don't wait for 'critical' signals, as things such as
* SEGV won't cause a core, then. Some non-HPUX platforms may need
* this, though, since apparently if we wait on some signals but not
* e.g. SEGV, the softsig thread will still wait around when the
* other threads were killed by the SEGV. */
for (i = 0; i < NSIG; i++) {
if (!sigismember(&os, i) && i != SIGSTOP && i != SIGKILL) {
sigaddset(&ss, i);
softsig_sigs[i].fatal = 1;
}
}
#endif /* defined(AFS_DARWIN_ENV) || defined(AFS_NBSD_ENV) */
while (1) {
void (*h) (int);
#if !defined(AFS_DARWIN_ENV) && (!defined(AFS_NBSD_ENV) || defined(AFS_NBSD50_ENV))
int sigw;
#endif
h = NULL;
for (i = 0; i < NSIG; i++) {
if (softsig_sigs[i].handler && !softsig_sigs[i].inited) {
sigaddset(&ss, i);
#if defined(AFS_DARWIN_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
pthread_sigmask (SIG_BLOCK, &ss, NULL);
sigdelset (&os, i);
#endif /* defined(AFS_DARWIN_ENV) || defined(AFS_NBSD_ENV) */
softsig_sigs[i].inited = 1;
}
if (softsig_sigs[i].pending) {
softsig_sigs[i].pending = 0;
h = softsig_sigs[i].handler;
break;
}
}
if (i == NSIG) {
#if defined(AFS_DARWIN_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
sigsuspend (&os);
#else /* !defined(AFS_DARWIN_ENV) && !defined(AFS_NBSD_ENV) */
sigwait(&ss, &sigw);
if (sigw != SIGUSR1) {
if (softsig_sigs[sigw].fatal)
exit(0);
softsig_sigs[sigw].pending = 1;
}
#endif /* defined(AFS_DARWIN_ENV) || defined(AFS_NBSD_ENV) */
} else if (h)
h(i);
}
return NULL;
}
开发者ID:haught,项目名称:openafs,代码行数:67,代码来源:softsig.c
示例5: mysleep
unsigned int mysleep(unsigned int nsecs)
{
#ifdef DEBUG
printf("DEBUG - mysleep(%u)\n", nsecs);
#endif
struct sigaction newact, oldact;
sigset_t newmask, oldmask, suspmask, blockedmask;
int issuspend = 0;/* SIGALRM是否被阻塞 */
int isblocked = 0;/* 是否存在未决的SIGALRM */
unsigned int unslept, slept;
unsigned int oldalarm;
oldalarm = alarm(0);
/* 保存以前的SIGALRM配置,并设置成我们需要的配置 */
newact.sa_handler = sig_alrm;
sigemptyset(&newact.sa_mask);
newact.sa_flags = 0;
sigaction(SIGALRM, &newact, &oldact);
/* 处理以前的SIGALRM */
/* 判断SIGALRM是否被阻塞 */
sigprocmask(SIG_BLOCK, NULL, &oldmask);
if (sigismember(&oldmask, SIGALRM)) {
/* SIGALRM被阻塞 */
issuspend = 1;
}
/* 判断是否存在未决的SIGALRM */
if (sigpending(&blockedmask) < 0) {
err_sys("sigpending error");
}
if (sigismember(&blockedmask, SIGALRM)) {
/* 存在未决的SIGALRM */
suspmask = oldmask;
isblocked = 1;
sigdelset(&suspmask, SIGALRM);
sigsuspend(&suspmask);
sigprocmask(SIG_SETMASK, &oldmask, NULL);
}
sigemptyset(&newmask);
sigaddset(&newmask, SIGALRM);
sigprocmask(SIG_BLOCK, &newmask, &oldmask);
#ifdef DEBUG
printf("DEBUG - oldalarm = %u\n", oldalarm);
#endif
if ((oldalarm != 0) && (oldalarm < nsecs) && (issuspend == 0)) {
/* 以前剩余的闹钟值比睡眠时间少且没有被阻塞 */
alarm(oldalarm);
}
else {
/* 以前剩余的闹钟值比睡眠时间多或者被阻塞 */
alarm(nsecs);
}
suspmask = oldmask;
sigdelset(&suspmask, SIGALRM);
sigsuspend(&suspmask);
unslept = alarm(0);
sigaction(SIGALRM, &oldact, NULL);
sigprocmask(SIG_SETMASK, &oldmask, NULL);
/* 计算实际睡眠时间 */
if ((oldalarm != 0) && (oldalarm < nsecs) && (issuspend == 0)) {
/* 以前的闹钟值比睡眠时间少 */
slept = oldalarm - unslept;
}
else {
/* 以前的闹钟值比睡眠时间多 */
slept = nsecs - unslept;
}
if (isblocked == 1) {
kill(getpid(), SIGALRM);
}
if (slept < oldalarm) {
/* 以前的闹钟值比实际睡眠时间多 */
alarm(oldalarm - slept);
return nsecs - slept;
}
else {
if (oldalarm != 0) {
kill(getpid(), SIGALRM);
}
return nsecs - slept;
}
return 0; /* 出错 */
}
开发者ID:xmuliushuo,项目名称:learn,代码行数:94,代码来源:mysleep.c
示例6: main
/* The main test function. */
int main(int argc, char * argv[])
{
int ret, status;
pid_t child, ctl;
sigset_t mask, pending;
/* Initialize output */
output_init();
/* block SIGUSR1 and SIGUSR2 */
ret = sigemptyset(&mask);
if (ret != 0)
{
UNRESOLVED(errno, "Failed to initialize signal set");
}
ret = sigaddset(&mask, SIGUSR1);
if (ret != 0)
{
UNRESOLVED(errno, "Failed to add SIGUSR1 to signal set");
}
ret = sigaddset(&mask, SIGUSR2);
if (ret != 0)
{
UNRESOLVED(errno, "Failed to add SIGUSR2 to signal set");
}
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
if (ret != 0)
{
UNRESOLVED(errno, "Sigprocmask failed");
}
/* Make the signals pending */
ret = kill(getpid(), SIGUSR1);
if (ret != 0)
{
UNRESOLVED(errno, "failed to kill with SIGUSR1");
}
ret = kill(getpid(), SIGUSR2);
if (ret != 0)
{
UNRESOLVED(errno, "failed to kill with SIGUSR2");
}
do
{
ret = sigpending(&pending);
if (ret != 0)
{
UNRESOLVED(errno, "failed to examine pending signal set");
}
ret = sigismember(&pending, SIGUSR1);
if (ret < 0)
{
UNRESOLVED(errno, "Unable to check signal USR1 presence");
}
if (ret == 1)
{
ret = sigismember(&pending, SIGUSR2);
if (ret < 0)
{
UNRESOLVED(errno, "Unable to check signal USR2 presence");
}
}
}
while (ret != 1);
#if VERBOSE > 0
output("SIGUSR1 and SIGUSR2 are pending, we can fork\n");
#endif
/* Create the child */
child = fork();
if (child == -1)
{
UNRESOLVED(errno, "Failed to fork");
}
/* child */
if (child == 0)
{
//.........这里部分代码省略.........
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:101,代码来源:12-1.c
示例7: CYG_TEST_INFO
void *pthread_entry1( void *arg)
{
sigset_t mask;
siginfo_t info;
struct timespec timeout;
int sig, sig2, err;
CYG_TEST_INFO( "Thread 1 running" );
// Should have inherited parent's signal mask
pthread_sigmask( 0, NULL, &mask );
CYG_TEST_CHECK( sigismember( &mask, SIGALRM),
"SIGALRM mask inherited");
CYG_TEST_CHECK( sigismember( &mask, SIGUSR1),
"SIGUSR1 mask inherited");
CYG_TEST_CHECK( sigismember( &mask, SIGUSR2),
"SIGUSR2 mask inherited");
CYG_TEST_CHECK( sigismember( &mask, SIGSEGV),
"SIGSEGV mask inherited");
// Make a full set
sigfillset( &mask );
// remove USR2 and ALRM signals
sigdelset( &mask, SIGUSR2 );
sigdelset( &mask, SIGALRM );
// Set signal mask
pthread_sigmask( SIG_SETMASK, &mask, NULL );
// Get main thread going again
sem_post( &sem );
// set up timeout
timeout.tv_sec = 10;
timeout.tv_nsec = 0;
CYG_TEST_INFO( "Thread1: calling sigtimedwait()");
// Wait for a signal to be delivered
sig = sigtimedwait( &mask, &info, &timeout );
sig2 = info.si_signo;
CYG_TEST_CHECK( sig == sig2, "sigtimedwait return value not equal");
CYG_TEST_CHECK( sig == SIGUSR1, "Signal not delivered");
while( sigusr2_called != 2 )
{
CYG_TEST_INFO( "Thread1: calling pause()");
pause();
}
errno = 0; // strictly correct to reset errno first
// now wait for SIGALRM to be delivered
CYG_TEST_INFO( "Thread1: calling pause()");
err = pause();
CYG_TEST_CHECK( -1==err, "pause returned -1");
CYG_TEST_CHECK( EINTR==errno, "errno set to EINTR");
// generate another SIGALRM and wait for it to be delivered too
// we need to mask it first though
// Make a full set
sigfillset( &mask );
// Set signal mask
pthread_sigmask( SIG_SETMASK, &mask, NULL );
alarm(1);
CYG_TEST_INFO( "Thread1: calling sigwait()");
err = sigwait( &mask, &sig);
CYG_TEST_CHECK( 0==err, "sigwait returned -1");
CYG_TEST_CHECK( sig==SIGALRM, "sigwait caught alarm");
CYG_TEST_INFO( "Thread1: calling pthread_exit()");
pthread_exit( (void *)((int)arg+sig2) );
}
开发者ID:axonim,项目名称:ecos-ax-som-bf609,代码行数:79,代码来源:signal1.c
示例8: main
int main(int argc, char **argv)
{
video_playback_setup *settings;
sigset_t allsignals;
struct sigaction action;
struct timespec req;
int i;
fflush(stdout);
vj_mem_init();
vevo_strict_init();
info = veejay_malloc();
if (!info) {
vj_mem_threaded_stop();
return 1;
}
settings = (video_playback_setup *) info->settings;
if(!check_command_line_options(argc, argv))
{
veejay_free(info);
return 0;
}
if(info->dump)
{
veejay_set_colors(0);
vj_event_init(NULL);
vj_effect_initialize(720,576,0);
vj_osc_allocate(VJ_PORT+2);
vj_event_dump();
vj_effect_dump();
fprintf(stdout, "Environment variables:\n\tSDL_VIDEO_HWACCEL\t\tSet to 1 to use SDL video hardware accel (default=on)\n\tVEEJAY_PERFORMANCE\t\tSet to \"quality\" or \"fastest\" (default is fastest)\n\tVEEJAY_AUTO_SCALE_PIXELS\tSet to 1 to convert between CCIR 601 and JPEG automatically (default=dont care)\n\tVEEJAY_INTERPOLATE_CHROMA\tSet to 1 if you wish to interpolate every chroma sample when scaling (default=0)\n\tVEEJAY_CAPTURE_DRIVER\t\tSet to \"unicap\" or \"v4lutils\" (default=v4lutils)\n\tVEEJAY_SDL_KEY_REPEAT_INTERVAL\tinterval of key pressed to repeat while pressed down.\n\tVEEJAY_PLAYBACK_CACHE\t\tSample cache size in MB - by default, veejay takes 30 percent of total RAM\n\tVEEJAY_SDL_KEY_REPEAT_DELAY\tDelay key repeat in ms\n\tVEEJAY_FULLSCREEN\t\tStart in fullscreen (1) or windowed (0) mode\n\tVEEJAY_SCREEN_GEOMETRY\t\tSpecifiy a geometry for veejay to position the video window.\n\tVEEJAY_SCREEN_SIZE\t\tSize of video window, defaults to full screen size.\n\tVEEJAY_RUN_MODE\t\t\tRun in \"classic\" (352x288 Dummy) or default (720x576). \n");
fprintf(stdout, "\n\n\tExample for bash:\n\t\t\t$ export VEEJAY_AUTO_SCALE_PIXEL=1\n");
veejay_free(info);
return 0;
}
if( vj_el_get_mem_size() == 0 )
prepare_cache_line( max_mem_, n_slots_ );
veejay_check_homedir( info );
sigsegfault_handler();
sigemptyset(&(settings->signal_set));
sigaddset(&(settings->signal_set), SIGINT);
sigaddset(&(settings->signal_set), SIGPIPE);
sigaddset(&(settings->signal_set), SIGILL);
// sigaddset(&(settings->signal_set), SIGSEGV);
sigaddset(&(settings->signal_set), SIGFPE );
sigaddset(&(settings->signal_set), SIGTERM );
sigaddset(&(settings->signal_set), SIGABRT);
sigaddset(&(settings->signal_set), SIGPWR );
sigaddset(&(settings->signal_set), SIGQUIT );
sigfillset( &allsignals );
action.sa_handler = donothing;
action.sa_mask = allsignals;
action.sa_flags = SA_SIGINFO | SA_ONESHOT ; //SA_RESTART | SA_RESETHAND;
signal( SIGPIPE, SIG_IGN );
for( i = 1; i < NSIG; i ++ )
if( sigismember( &(settings->signal_set), i ))
sigaction( i, &action, 0 );
char *mem_func = get_memcpy_descr();
if(mem_func)
{
veejay_msg(VEEJAY_MSG_INFO, "Using SIMD %s", mem_func);
free(mem_func);
}
info->use_keyb = use_keyb;
info->use_mouse = use_mouse;
info->show_cursor = show_cursor;
if(veejay_init(
info,
default_geometry_x,
default_geometry_y,
NULL,
live,
ta )< 0)
{
veejay_msg(VEEJAY_MSG_ERROR, "Cannot start veejay");
return 0;
}
if(auto_loop)
veejay_auto_loop(info);
//.........这里部分代码省略.........
开发者ID:d-j-a-y,项目名称:veejay-dyne-outdated,代码行数:101,代码来源:veejay.c
示例9: dpram_thread
static int dpram_thread(void *data)
{
int ret = 0;
//unsigned long flags;
struct file *filp;
dpram_task = current;
daemonize("dpram_thread");
//reparent_to_init(); // for 2.6 kernel porting : this seems not to be used in driver
// current->tty = NULL; // for 2.6 kernel porting
strcpy(current->comm, "multipdp");
/* set signals to accept */
//spin_lock_irqsave(¤t->sigmask_lock, flags); // for 2.6 kernel proting
siginitsetinv(¤t->blocked, sigmask(SIGUSR1));
//recalc_sigpending(current);
recalc_sigpending();
//spin_unlock_irqrestore(¤t->sigmask_lock, flags); // for 2.6 kernel proting
filp = dpram_open();
if (filp == NULL) {
goto out;
}
dpram_filp = filp;
/* send start signal */
complete(&dpram_complete);
while (1) {
ret = dpram_poll(filp);
if (ret == -ERESTARTSYS) {
if (sigismember(¤t->pending.signal, SIGUSR1)) {
printk(KERN_ERR "MULTIPDP (%s) DPRAM device communication interrupted\n",__func__);
sigdelset(¤t->pending.signal, SIGUSR1);
recalc_sigpending();
ret = 0;
break;
}
}
else if (ret < 0) {
EPRINTK("dpram_poll() failed\n");
break;
}
else {
char ch;
dpram_read(dpram_filp, &ch, sizeof(ch));
if (ch == 0x7f) {
pdp_demux();
}
}
try_to_freeze();
}
dpram_close(filp);
dpram_filp = NULL;
out:
dpram_task = NULL;
/* send finish signal and exit */
complete_and_exit(&dpram_complete, ret);
}
开发者ID:sirgatez,项目名称:Android-Eclair-Kernel-Samsung-Modules-Source-v2.6.29.6,代码行数:69,代码来源:multipdp.c
示例10: stress_sigpending
/*
* stress_sigpending
* stress sigpending system call
*/
int stress_sigpending(
uint64_t *const counter,
const uint32_t instance,
const uint64_t max_ops,
const char *name)
{
struct sigaction new_action;
sigset_t sigset;
const pid_t mypid = getpid();
(void)instance;
memset(&new_action, 0, sizeof new_action);
new_action.sa_handler = stress_usr1_handler;
sigemptyset(&new_action.sa_mask);
new_action.sa_flags = 0;
if (sigaction(SIGUSR1, &new_action, NULL) < 0) {
pr_failed_err(name, "sigaction");
return EXIT_FAILURE;
}
do {
sigemptyset(&sigset);
sigaddset(&sigset, SIGUSR1);
if (sigprocmask(SIG_SETMASK, &sigset, NULL) < 0) {
pr_failed_err(name, "sigprocmask");
return EXIT_FAILURE;
}
(void)kill(mypid, SIGUSR1);
if (sigpending(&sigset) < 0) {
pr_failed_err(name, "sigpending");
continue;
}
/* We should get a SIGUSR1 here */
if (!sigismember(&sigset, SIGUSR1)) {
pr_failed_err(name, "sigismember");
continue;
}
/* Unmask signal, signal is handled */
sigemptyset(&sigset);
sigprocmask(SIG_SETMASK, &sigset, NULL);
/* And it is no longer pending */
if (sigpending(&sigset) < 0) {
pr_failed_err(name, "sigpending");
continue;
}
if (sigismember(&sigset, SIGUSR1)) {
pr_failed_err(name, "sigismember");
continue;
}
/* Success! */
(*counter)++;
} while (opt_do_run && (!max_ops || *counter < max_ops));
return EXIT_SUCCESS;
}
开发者ID:srikanth007m,项目名称:stress-ng,代码行数:65,代码来源:stress-sigpending.c
示例11: do_exec
//.........这里部分代码省略.........
tell_fs(CHDIR, who, FALSE, 0); /* switch to the user's FS environ. */
fd = allowed(name_buf, &s_buf, X_BIT); /* is file executable? */
if (fd < 0) return(fd); /* file was not executable */
/* Read the file header and extract the segment sizes. */
sc = (stk_bytes + CLICK_SIZE - 1) >> CLICK_SHIFT;
m = read_header(fd, &ft, &text_bytes, &data_bytes, &bss_bytes,
&tot_bytes, &sym_bytes, sc, &pc);
if (m < 0) {
close(fd); /* something wrong with header */
return(ENOEXEC);
}
/* Fetch the stack from the user before destroying the old core image. */
src = (vir_bytes) stack_ptr;
dst = (vir_bytes) mbuf;
r = sys_copy(who, D, (phys_bytes) src,
MM_PROC_NR, D, (phys_bytes) dst, (phys_bytes)stk_bytes);
if (r != OK) {
close(fd); /* can't fetch stack (e.g. bad virtual addr) */
return(EACCES);
}
/* Can the process' text be shared with that of one already running? */
sh_mp = find_share(rmp, s_buf.st_ino, s_buf.st_dev, s_buf.st_ctime);
/* Allocate new memory and release old memory. Fix map and tell kernel. */
r = new_mem(sh_mp, text_bytes, data_bytes, bss_bytes, stk_bytes, tot_bytes);
if (r != OK) {
close(fd); /* insufficient core or program too big */
return(r);
}
/* Save file identification to allow it to be shared. */
rmp->mp_ino = s_buf.st_ino;
rmp->mp_dev = s_buf.st_dev;
rmp->mp_ctime = s_buf.st_ctime;
/* Patch up stack and copy it from MM to new core image. */
vsp = (vir_bytes) rmp->mp_seg[S].mem_vir << CLICK_SHIFT;
vsp += (vir_bytes) rmp->mp_seg[S].mem_len << CLICK_SHIFT;
vsp -= stk_bytes;
patch_ptr(mbuf, vsp);
src = (vir_bytes) mbuf;
r = sys_copy(MM_PROC_NR, D, (phys_bytes) src,
who, D, (phys_bytes) vsp, (phys_bytes)stk_bytes);
if (r != OK) panic("do_exec stack copy err", NO_NUM);
/* Read in text and data segments. */
if (sh_mp != NULL) {
lseek(fd, (off_t) text_bytes, SEEK_CUR); /* shared: skip text */
} else {
load_seg(fd, T, text_bytes);
}
load_seg(fd, D, data_bytes);
#if (SHADOWING == 1)
if (lseek(fd, (off_t)sym_bytes, SEEK_CUR) == (off_t) -1) ; /* error */
if (relocate(fd, (unsigned char *)mbuf) < 0) ; /* error */
pc += (vir_bytes) rp->mp_seg[T].mem_vir << CLICK_SHIFT;
#endif
close(fd); /* don't need exec file any more */
/* Take care of setuid/setgid bits. */
if ((rmp->mp_flags & TRACED) == 0) { /* suppress if tracing */
if (s_buf.st_mode & I_SET_UID_BIT) {
rmp->mp_effuid = s_buf.st_uid;
tell_fs(SETUID,who, (int)rmp->mp_realuid, (int)rmp->mp_effuid);
}
if (s_buf.st_mode & I_SET_GID_BIT) {
rmp->mp_effgid = s_buf.st_gid;
tell_fs(SETGID,who, (int)rmp->mp_realgid, (int)rmp->mp_effgid);
}
}
/* Save offset to initial argc (for ps) */
rmp->mp_procargs = vsp;
/* Fix 'mproc' fields, tell kernel that exec is done, reset caught sigs. */
for (sn = 1; sn <= _NSIG; sn++) {
if (sigismember(&rmp->mp_catch, sn)) {
sigdelset(&rmp->mp_catch, sn);
rmp->mp_sigact[sn].sa_handler = SIG_DFL;
sigemptyset(&rmp->mp_sigact[sn].sa_mask);
}
}
rmp->mp_flags &= ~SEPARATE; /* turn off SEPARATE bit */
rmp->mp_flags |= ft; /* turn it on for separate I & D files */
new_sp = (char *) vsp;
tell_fs(EXEC, who, 0, 0); /* allow FS to handle FD_CLOEXEC files */
/* System will save command line for debugging, ps(1) output, etc. */
basename = strrchr(name_buf, '/');
if (basename == NULL) basename = name_buf; else basename++;
sys_exec(who, new_sp, rmp->mp_flags & TRACED, basename, pc);
return(OK);
}
开发者ID:54niyu,项目名称:minix,代码行数:101,代码来源:exec.c
示例12: signal_handler_init
/* Handlers intialization */
void
signal_handler_init(int remember)
{
sigset_t sset;
int sig;
struct sigaction act, oact;
int n;
#ifdef HAVE_PIPE2
n = pipe2(signal_pipe, O_CLOEXEC | O_NONBLOCK);
#else
n = pipe(signal_pipe);
#endif
assert(!n);
if (n)
log_message(LOG_INFO, "BUG - pipe in signal_handler_init failed (%s), please report", strerror(errno));
#ifndef HAVE_PIPE2
fcntl(signal_pipe[0], F_SETFL, O_NONBLOCK | fcntl(signal_pipe[0], F_GETFL));
fcntl(signal_pipe[1], F_SETFL, O_NONBLOCK | fcntl(signal_pipe[1], F_GETFL));
fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC | fcntl(signal_pipe[0], F_GETFD));
fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC | fcntl(signal_pipe[1], F_GETFD));
#endif
signal_SIGHUP_handler = NULL;
signal_SIGINT_handler = NULL;
signal_SIGTERM_handler = NULL;
signal_SIGCHLD_handler = NULL;
signal_SIGUSR1_handler = NULL;
signal_SIGUSR2_handler = NULL;
/* Ignore all signals set to default (except essential ones) */
sigfillset(&sset);
sigdelset(&sset, SIGILL);
sigdelset(&sset, SIGFPE);
sigdelset(&sset, SIGSEGV);
sigdelset(&sset, SIGBUS);
sigdelset(&sset, SIGKILL);
sigdelset(&sset, SIGSTOP);
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (remember) {
sigemptyset(&ign_sig);
sigemptyset(&dfl_sig);
}
for (sig = 1; sig <= SIGRTMAX; sig++) {
if (sigismember(&sset, sig)){
sigaction(sig, NULL, &oact);
/* Remember the original disposition, and ignore
* any default action signals
*/
if (oact.sa_handler == SIG_IGN) {
if (remember)
sigaddset(&ign_sig, sig);
}
else {
sigaction(sig, &act, NULL);
if (remember)
sigaddset(&dfl_sig, sig);
}
}
}
}
开发者ID:Oefenweb,项目名称:keepalived,代码行数:71,代码来源:signals.c
示例13: main
int main()
{
sigset_t set,pendset;
struct sigaction action1,action2;
//initialize the set empty
if(sigemptyset(&set)<0)
{
perror("sigemptyset\n");
exit(1);
}
if(sigaddset(&set,SIGQUIT)<0)
{
perror("sigaddset\n");
exit(1);
}
if(sigaddset(&set,SIGINT)<0)
{
perror("sigaddset\n");
exit(1);
}
if(sigismember(&set,SIGINT))
{
sigemptyset(&action1.sa_mask);
action1.sa_handler=my_func;
action1.sa_flags=0;
sigaction(SIGINT,&action1,NULL);
}
if(sigismember(&set,SIGQUIT))
{
sigemptyset(&action2.sa_mask);
action2.sa_handler=SIG_DFL;
action2.sa_flags=0;
sigaction(SIGQUIT,&action2,NULL);
}
if(sigprocmask(SIG_BLOCK,&set,NULL)<0)
{
perror("sigprocmask");
exit(1);
}
else
{
printf("Signal set was blocked,Press any key!\n");
getchar();
}
if(sigprocmask(SIG_UNBLOCK,&set,NULL)<0)
{
perror("sigprocmask");
exit(1);
}
else
{
printf("Signal set is in unblock state.\n");
}
while(1);
exit(0);
}
开发者ID:no7dw,项目名称:cpp-learning,代码行数:67,代码来源:sigset3.c
示例14: nfsd
/*
* This is the NFS server kernel thread
*/
static void
nfsd(struct svc_rqst *rqstp)
{
struct svc_serv *serv = rqstp->rq_server;
struct fs_struct *fsp;
int err;
struct nfsd_list me;
sigset_t shutdown_mask, allowed_mask;
/* Lock module and set up kernel thread */
lock_kernel();
daemonize("nfsd");
current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
/* After daemonize() this kernel thread shares current->fs
* with the init process. We need to create files with a
* umask of 0 instead of init's umask. */
fsp = copy_fs_struct(current->fs);
if (!fsp) {
printk("Unable to start nfsd thread: out of memory\n");
goto out;
}
exit_fs(current);
current->fs = fsp;
current->fs->umask = 0;
siginitsetinv(&shutdown_mask, SHUTDOWN_SIGS);
siginitsetinv(&allowed_mask, ALLOWED_SIGS);
nfsdstats.th_cnt++;
lockd_up(); /* start lockd */
me.task = current;
list_add(&me.list, &nfsd_list);
unlock_kernel();
/*
* We want less throttling in balance_dirty_pages() so that nfs to
* localhost doesn't cause nfsd to lock up due to all the client's
* dirty pages.
*/
current->flags |= PF_LESS_THROTTLE;
/*
* The main request loop
*/
for (;;) {
/* Block all but the shutdown signals */
sigprocmask(SIG_SETMASK, &shutdown_mask, NULL);
/*
* Find a socket with data available and call its
* recvfrom routine.
*/
while ((err = svc_recv(serv, rqstp,
60*60*HZ)) == -EAGAIN)
;
if (err < 0)
break;
update_thread_usage(atomic_read(&nfsd_busy));
atomic_inc(&nfsd_busy);
/* Lock the export hash tables for reading. */
exp_readlock();
/* Process request with signals blocked. */
sigprocmask(SIG_SETMASK, &allowed_mask, NULL);
svc_process(serv, rqstp);
/* Unlock export hash tables */
exp_readunlock();
update_thread_usage(atomic_read(&nfsd_busy));
atomic_dec(&nfsd_busy);
}
if (err != -EINTR) {
printk(KERN_WARNING "nfsd: terminating on error %d\n", -err);
} else {
unsigned int signo;
for (signo = 1; signo <= _NSIG; signo++)
if (sigismember(¤t->pending.signal, signo) &&
!sigismember(¤t->blocked, signo))
break;
err = signo;
}
lock_kernel();
/* Release lockd */
lockd_down();
/* Check if this is last thread */
if (serv->sv_nrthreads==1) {
//.........这里部分代码省略.........
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:101,代码来源:nfssvc.c
示例15: exec_conf
static int exec_conf(void)
{
int pipefd[2], stat, size;
struct sigaction sa;
sigset_t sset, osset;
sigemptyset(&sset);
sigaddset(&sset, SIGINT);
sigprocmask(SIG_BLOCK, &sset, &osset);
signal(SIGINT, SIG_DFL);
sa.sa_handler = winch_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sigaction(SIGWINCH, &sa, NULL);
*argptr++ = NULL;
pipe(pipefd);
pid = fork();
if (pid == 0) {
sigprocmask(SIG_SETMASK, &osset, NULL);
dup2(pipefd[1], 2);
close(pipefd[0]);
close(pipefd[1]);
execv(args[0], args);
_exit(EXIT_FAILURE);
}
close(pipefd[1]);
bufptr = input_buf;
while (1) {
size = input_buf + sizeof(input_buf) - bufptr;
size = read(pipefd[0], bufptr, size);
if (size <= 0) {
if (size < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
perror("read");
}
break;
}
bufptr += size;
}
*bufptr++ = 0;
close(pipefd[0]);
waitpid(pid, &stat, 0);
if (do_resize) {
init_wsize();
do_resize = 0;
sigprocmask(SIG_SETMASK, &osset, NULL);
return -1;
}
if (WIFSIGNALED(stat)) {
printf("\finterrupted(%d)\n", WTERMSIG(stat));
exit(1);
}
#if 0
printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
sleep(1);
#endif
sigpending(&sset);
if (sigismember(&sset, SIGINT)) {
printf("\finterrupted\n");
exit(1);
}
sigprocmask(SIG_SETMASK, &osset, NULL);
return WEXITSTATUS(stat);
}
开发者ID:hiddeate2m,项目名称:rtnet,代码行数:72,代码来源:mconf.c
示例16: sigend
/* Terminate handler */
static void
sigend(void *v, int sig)
{
int status;
int ret;
int wait_count = 0;
sigset_t old_set, child_wait;
struct timespec timeout = {
.tv_sec = CHILD_WAIT_SECS,
.tv_nsec = 0
};
struct timeval start_time, now;
/* register the terminate thread */
thread_add_terminate_event(master);
log_message(LOG_INFO, "Stopping");
sigprocmask(0, NULL, &old_set);
if (!sigismember(&old_set, SIGCHLD)) {
sigemptyset(&child_wait);
sigaddset(&child_wait, SIGCHLD);
sigprocmask(SIG_BLOCK, &child_wait, NULL);
}
if (vrrp_child > 0) {
kill(vrrp_child, SIGTERM);
wait_count++;
}
if (checkers_child > 0) {
kill(checkers_child, SIGTERM);
wait_count++;
}
gettimeofday(&start_time, NULL);
while (wait_count) {
ret = sigtimedwait(&child_wait, NULL, &timeout);
if (ret == -1) {
if (errno == EINTR)
continue;
if (errno == EAGAIN)
break;
}
if (vrrp_child > 0 && vrrp_child == waitpid(vrrp_child, &status, WNOHANG)) {
report_child_status(status, vrrp_child, PROG_VRRP);
wait_count--;
}
if (checkers_child > 0 && checkers_child == waitpid(checkers_child, &status, WNOHANG)) {
report_child_status(status, checkers_child, PROG_CHECK);
wait_count--;
}
if (wait_count) {
gettimeofday(&now, NULL);
if (now.tv_usec < start_time.tv_usec) {
timeout.tv_nsec = (start_time.tv_usec - now.tv_usec) * 1000;
timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
} else if (now.tv_usec == start_time.tv_usec) {
timeout.tv_nsec = 0;
timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
} else {
timeout.tv_nsec = (1000000L + start_time.tv_usec - now.tv_usec) * 1000;
timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec + 1);
}
timeout.tv_nsec = (start_time.tv_usec - now.tv_usec) * 1000;
timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
if (timeout.tv_nsec < 0) {
timeout.tv_nsec += 1000000000L;
timeout.tv_sec--;
}
}
}
if (!sigismember(&old_set, SIGCHLD))
sigprocmask(SIG_UNBLOCK, &child_wait, NULL);
}
/* Initialize signal handler */
static void
signal_init(void)
{
signal_handler_init();
signal_set(SIGHUP, propogate_signal, NULL);
signal_set(SIGUSR1, propogate_signal, NULL);
signal_set(SIGUSR2, propogate_signal, NULL);
signal_set(SIGINT, sigend, NULL);
signal_set(SIGTERM, sigend, NULL);
signal_ignore(SIGPIPE);
}
开发者ID:Linbing,项目名称:keepalived,代码行数:91,代码来源:main.c
示例17: rpmsqIsCaught
int rpmsqIsCaught(int signum)
{
return sigismember(&rpmsqCaught, signum);
}
开发者ID:OlegGirko,项目名称:rpm,代码行数:4,代码来源:rpmsq.c
示例18: group_signal_handler
static int group_signal_handler(pid_t pid, FAR void *arg)
{
FAR struct group_signal_s *info = (FAR struct group_signal_s *)arg;
FAR struct tcb_s *tcb;
FAR sigactq_t *sigact;
int ret;
/* Get the TCB associated with the group member */
tcb = sched_gettcb(pid);
DEBUGASSERT(tcb != NULL && tcb->group != NULL && info != NULL);
if (tcb)
{
/* Set this one as the default if we have not already set the default. */
if (!info->dtcb)
{
info->dtcb = tcb;
}
/* Is the thread waiting for this signal (in this case, the signal is
* probably blocked).
*/
if (sigismember(&tcb->sigwaitmask, info->siginfo->si_signo) && !info->atcb)
{
/* Yes.. This means that the task is suspended, waiting for this
* signal to occur. Stop looking and use this TCB. The
* requirement is this: If a task group receives a signal and
* more than one thread is waiting on that signal, then one and
* only one indeterminate thread out of that waiting group will
* receive the signal.
*/
ret = sig_tcbdispatch(tcb, info->siginfo);
if (ret < 0)
{
return ret;
}
/* Limit to one thread */
info->atcb = tcb;
if (info->ptcb != NULL)
{
return 1; /* Terminate the search */
}
|
请发表评论