本文整理汇总了C++中recalc_sigpending函数的典型用法代码示例。如果您正苦于以下问题:C++ recalc_sigpending函数的具体用法?C++ recalc_sigpending怎么用?C++ recalc_sigpending使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recalc_sigpending函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sys_rt_sigreturn
int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7, unsigned long r8,
struct pt_regs *regs)
{
struct rt_sigframe *rt_sf;
struct sigcontext_struct sigctx;
struct sigregs *sr;
int ret;
elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */
sigset_t set;
stack_t st;
unsigned long prevsp;
rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))
|| copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set))
|| copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st)))
goto badframe;
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(¤t->sigmask_lock);
current->blocked = set;
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
rt_sf++; /* Look at next rt_sigframe */
if (rt_sf == (struct rt_sigframe *)(sigctx.regs)) {
/* Last stacked signal - restore registers -
* sigctx is initialized to point to the
* preamble frame (where registers are stored)
* see handle_signal()
*/
sr = (struct sigregs *) sigctx.regs;
if (regs->msr & MSR_FP )
giveup_fpu(current);
if (copy_from_user(saved_regs, &sr->gp_regs,
sizeof(sr->gp_regs)))
goto badframe;
saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
| (saved_regs[PT_MSR] & MSR_USERCHANGE);
saved_regs[PT_SOFTE] = regs->softe;
memcpy(regs, saved_regs, GP_REGS_SIZE);
if (copy_from_user(current->thread.fpr, &sr->fp_regs,
sizeof(sr->fp_regs)))
goto badframe;
/* This function sets back the stack flags into
the current task structure. */
sys_sigaltstack(&st, NULL);
ret = regs->result;
} else {
/* More signals to go */
/* Set up registers for next signal handler */
regs->gpr[1] = (unsigned long)rt_sf - __SIGNAL_FRAMESIZE;
if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx)))
goto badframe;
sr = (struct sigregs *) sigctx.regs;
regs->gpr[3] = ret = sigctx.signal;
/* Get the siginfo */
get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo);
/* Get the ucontext */
get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc);
regs->gpr[6] = (unsigned long) rt_sf;
regs->link = (unsigned long) &sr->tramp;
regs->nip = sigctx.handler;
if (get_user(prevsp, &sr->gp_regs[PT_R1])
|| put_user(prevsp, (unsigned long *) regs->gpr[1]))
goto badframe;
}
return ret;
badframe:
do_exit(SIGSEGV);
}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:74,代码来源:signal.c
示例2: ckpt_restore_signals
int ckpt_restore_signals(ckpt_desc_t desc)
{
int i;
int ret;
stack_t sigstack;
sigset_t sigblocked;
log_restore_signals("restoring sigstack ...");
if (ckpt_read(desc, &sigstack, sizeof(stack_t)) != sizeof(stack_t)) {
log_err("failed to get sigstack");
return -EIO;
}
ret = compat_sigaltstack(current, &sigstack, NULL, 0);
if (ret) {
log_err("failed to restore sigstack (ret=%d)", ret);
return ret;
}
log_restore_signals("restoring sigblocked ...");
if (ckpt_read(desc, &sigblocked, sizeof(sigset_t)) != sizeof(sigset_t)) {
log_err("failed to restore sigstack");
return -EIO;
}
sigdelsetmask(&sigblocked, sigmask(SIGKILL) | sigmask(SIGSTOP));
spin_lock_irq(¤t->sighand->siglock);
current->blocked = sigblocked;
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
log_restore_signals("restoring pending ...");
ret = ckpt_restore_sigpending(¤t->pending, 0, desc);
if (ret) {
log_err("failed to restore pending");
return ret;
}
ret = ckpt_restore_sigpending(¤t->signal->shared_pending, 1, desc);
if (ret) {
log_err("failed to restore shared_pending");
return ret;
}
log_restore_signals("restoring sigaction ...");
for (i = 0; i < _NSIG; i++) {
struct k_sigaction sigaction;
if (ckpt_read(desc, &sigaction, sizeof(struct k_sigaction)) != sizeof(struct k_sigaction)) {
log_err("failed to get sigaction");
return -EIO;
}
if ((i != SIGKILL - 1) && (i != SIGSTOP - 1)) {
ret = do_sigaction(i + 1, &sigaction, 0);
if (ret) {
log_err("failed to restore sigaction (ret=%d)", ret);
return ret;
}
}
}
log_restore_pos(desc);
return 0;
}
开发者ID:virthub,项目名称:virthub,代码行数:64,代码来源:restore.c
示例3: do_signal
/*
* Note that 'init' is a special process: it doesn't get signals it doesn't
* want to handle. Thus you cannot kill init even with a SIGKILL even by
* mistake.
*/
int do_signal(sigset_t *oldset, struct pt_regs *regs)
{
siginfo_t info;
struct k_sigaction ka;
unsigned long frame, newsp;
int signr, ret;
if (!oldset)
oldset = ¤t->blocked;
newsp = frame = 0;
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (TRAP(regs) == 0x0C00 /* System Call! */
&& regs->ccr & 0x10000000 /* error signalled */
&& ((ret = regs->gpr[3]) == ERESTARTSYS
|| ret == ERESTARTNOHAND || ret == ERESTARTNOINTR
|| ret == ERESTART_RESTARTBLOCK)) {
if (signr > 0
&& (ret == ERESTARTNOHAND || ret == ERESTART_RESTARTBLOCK
|| (ret == ERESTARTSYS
&& !(ka.sa.sa_flags & SA_RESTART)))) {
/* make the system call return an EINTR error */
regs->result = -EINTR;
regs->gpr[3] = EINTR;
/* note that the cr0.SO bit is already set */
} else {
regs->nip -= 4; /* Back up & retry system call */
regs->result = 0;
regs->trap = 0;
if (ret == ERESTART_RESTARTBLOCK)
regs->gpr[0] = __NR_restart_syscall;
else
regs->gpr[3] = regs->orig_gpr3;
}
}
if (signr == 0)
return 0; /* no signals delivered */
if ((ka.sa.sa_flags & SA_ONSTACK) && current->sas_ss_size
&& !on_sig_stack(regs->gpr[1]))
newsp = current->sas_ss_sp + current->sas_ss_size;
else
newsp = regs->gpr[1];
newsp &= ~0xfUL;
/* Whee! Actually deliver the signal. */
if (ka.sa.sa_flags & SA_SIGINFO)
handle_rt_signal(signr, &ka, &info, oldset, regs, newsp);
else
handle_signal(signr, &ka, &info, oldset, regs, newsp);
if (!(ka.sa.sa_flags & SA_NODEFER)) {
spin_lock_irq(¤t->sighand->siglock);
sigorsets(¤t->blocked,¤t->blocked,&ka.sa.sa_mask);
sigaddset(¤t->blocked, signr);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
}
return 1;
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:70,代码来源:signal.c
示例4: do_sigreturn
asmlinkage void do_sigreturn(struct pt_regs *regs)
{
struct signal_frame __user *sf;
unsigned long up_psr, pc, npc;
sigset_t set;
__siginfo_fpu_t __user *fpu_save;
__siginfo_rwin_t __user *rwin_save;
int err;
/* Always make any pending restarted system calls return -EINTR */
current_thread_info()->restart_block.fn = do_no_restart_syscall;
synchronize_user_stack();
sf = (struct signal_frame __user *) regs->u_regs[UREG_FP];
/* 1. Make sure we are not getting garbage from the user */
if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
goto segv_and_exit;
if (((unsigned long) sf) & 3)
goto segv_and_exit;
err = __get_user(pc, &sf->info.si_regs.pc);
err |= __get_user(npc, &sf->info.si_regs.npc);
if ((pc | npc) & 3)
goto segv_and_exit;
/* 2. Restore the state */
up_psr = regs->psr;
err |= __copy_from_user(regs, &sf->info.si_regs, sizeof(struct pt_regs));
/* User can only change condition codes and FPU enabling in %psr. */
regs->psr = (up_psr & ~(PSR_ICC | PSR_EF))
| (regs->psr & (PSR_ICC | PSR_EF));
/* Prevent syscall restart. */
pt_regs_clear_syscall(regs);
err |= __get_user(fpu_save, &sf->fpu_save);
if (fpu_save)
err |= restore_fpu_state(regs, fpu_save);
err |= __get_user(rwin_save, &sf->rwin_save);
if (rwin_save)
err |= restore_rwin_state(rwin_save);
/* This is pretty much atomic, no amount locking would prevent
* the races which exist anyways.
*/
err |= __get_user(set.sig[0], &sf->info.si_mask);
err |= __copy_from_user(&set.sig[1], &sf->extramask,
(_NSIG_WORDS-1) * sizeof(unsigned int));
if (err)
goto segv_and_exit;
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(¤t->sighand->siglock);
current->blocked = set;
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
return;
segv_and_exit:
force_sig(SIGSEGV, current);
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:67,代码来源:signal_32.c
示例5: sis1100_irq_thread
int
#else
void
#endif
sis1100_irq_thread(void* data)
{
struct sis1100_softc* sc=(struct sis1100_softc*)data;
enum handlercomm command;
DECLARE_SPINLOCKFLAGS(flags);
#ifdef __linux__
#if LINUX_VERSION_CODE < 0x20600
daemonize();
snprintf(current->comm, sizeof(current->comm), "sis1100_%02d", sc->unit);
SPIN_LOCK_IRQSAVE(current->sigmask_lock, flags);
sigemptyset(¤t->blocked);
recalc_sigpending(current);
SPIN_UNLOCK_IRQRESTORE(current->sigmask_lock, flags);
#endif
#endif /*__linux__*/
while (1) {
#ifdef __NetBSD__
tsleep(&sc->handler_wait, PCATCH, "thread_vmeirq", 0);
#elif __linux__
/* prepare to sleep */
__set_current_state(TASK_INTERRUPTIBLE);
/* don't sleep if command!=0 */
if (sc->handlercommand.command)
__set_current_state(TASK_RUNNING);
else
schedule();
#endif
if (kthread_should_stop())
return 0;
SPIN_LOCK_IRQSAVE(sc->handlercommand.lock, flags);
command=sc->handlercommand.command;
sc->handlercommand.command=0;
SPIN_UNLOCK_IRQRESTORE(sc->handlercommand.lock, flags);
#if 0
pERROR(sc, "irq_thread: command=0x%x", command);
#endif
_sis1100_irq_thread(sc, command);
#ifdef __linux__
if (signal_pending (current)) {
SPIN_LOCK_IRQSAVE(current->SIGMASK_LOCK, flags);
flush_signals(current);
SPIN_UNLOCK_IRQRESTORE(current->SIGMASK_LOCK, flags);
}
#endif /*__linux__*/
}
#ifdef __linux__
return 0;
#endif
}
开发者ID:cjpl,项目名称:mdaq-midas,代码行数:61,代码来源:sis1100_irq_thread.c
示例6: sparc64_set_context
/* {set, get}context() needed for 64-bit SparcLinux userland. */
asmlinkage void sparc64_set_context(struct pt_regs *regs)
{
struct ucontext __user *ucp = (struct ucontext __user *)
regs->u_regs[UREG_I0];
mc_gregset_t __user *grp;
unsigned long pc, npc, tstate;
unsigned long fp, i7;
unsigned char fenab;
int err;
flush_user_windows();
if (get_thread_wsaved() ||
(((unsigned long)ucp) & (sizeof(unsigned long)-1)) ||
(!__access_ok(ucp, sizeof(*ucp))))
goto do_sigsegv;
grp = &ucp->uc_mcontext.mc_gregs;
err = __get_user(pc, &((*grp)[MC_PC]));
err |= __get_user(npc, &((*grp)[MC_NPC]));
if (err || ((pc | npc) & 3))
goto do_sigsegv;
if (regs->u_regs[UREG_I1]) {
sigset_t set;
if (_NSIG_WORDS == 1) {
if (__get_user(set.sig[0], &ucp->uc_sigmask.sig[0]))
goto do_sigsegv;
} else {
if (__copy_from_user(&set, &ucp->uc_sigmask, sizeof(sigset_t)))
goto do_sigsegv;
}
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(¤t->sighand->siglock);
current->blocked = set;
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
}
if (test_thread_flag(TIF_32BIT)) {
pc &= 0xffffffff;
npc &= 0xffffffff;
}
regs->tpc = pc;
regs->tnpc = npc;
err |= __get_user(regs->y, &((*grp)[MC_Y]));
err |= __get_user(tstate, &((*grp)[MC_TSTATE]));
regs->tstate &= ~(TSTATE_ASI | TSTATE_ICC | TSTATE_XCC);
regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
err |= __get_user(regs->u_regs[UREG_G1], (&(*grp)[MC_G1]));
err |= __get_user(regs->u_regs[UREG_G2], (&(*grp)[MC_G2]));
err |= __get_user(regs->u_regs[UREG_G3], (&(*grp)[MC_G3]));
err |= __get_user(regs->u_regs[UREG_G4], (&(*grp)[MC_G4]));
err |= __get_user(regs->u_regs[UREG_G5], (&(*grp)[MC_G5]));
err |= __get_user(regs->u_regs[UREG_G6], (&(*grp)[MC_G6]));
err |= __get_user(regs->u_regs[UREG_G7], (&(*grp)[MC_G7]));
err |= __get_user(regs->u_regs[UREG_I0], (&(*grp)[MC_O0]));
err |= __get_user(regs->u_regs[UREG_I1], (&(*grp)[MC_O1]));
err |= __get_user(regs->u_regs[UREG_I2], (&(*grp)[MC_O2]));
err |= __get_user(regs->u_regs[UREG_I3], (&(*grp)[MC_O3]));
err |= __get_user(regs->u_regs[UREG_I4], (&(*grp)[MC_O4]));
err |= __get_user(regs->u_regs[UREG_I5], (&(*grp)[MC_O5]));
err |= __get_user(regs->u_regs[UREG_I6], (&(*grp)[MC_O6]));
err |= __get_user(regs->u_regs[UREG_I7], (&(*grp)[MC_O7]));
err |= __get_user(fp, &(ucp->uc_mcontext.mc_fp));
err |= __get_user(i7, &(ucp->uc_mcontext.mc_i7));
err |= __put_user(fp,
(&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[6])));
err |= __put_user(i7,
(&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[7])));
err |= __get_user(fenab, &(ucp->uc_mcontext.mc_fpregs.mcfpu_enab));
if (fenab) {
unsigned long *fpregs = current_thread_info()->fpregs;
unsigned long fprs;
fprs_write(0);
err |= __get_user(fprs, &(ucp->uc_mcontext.mc_fpregs.mcfpu_fprs));
if (fprs & FPRS_DL)
err |= copy_from_user(fpregs,
&(ucp->uc_mcontext.mc_fpregs.mcfpu_fregs),
(sizeof(unsigned int) * 32));
if (fprs & FPRS_DU)
err |= copy_from_user(fpregs+16,
((unsigned long __user *)&(ucp->uc_mcontext.mc_fpregs.mcfpu_fregs))+16,
(sizeof(unsigned int) * 32));
err |= __get_user(current_thread_info()->xfsr[0],
&(ucp->uc_mcontext.mc_fpregs.mcfpu_fsr));
err |= __get_user(current_thread_info()->gsr[0],
&(ucp->uc_mcontext.mc_fpregs.mcfpu_gsr));
regs->tstate &= ~TSTATE_PEF;
}
if (err)
goto do_sigsegv;
return;
do_sigsegv:
force_sig(SIGSEGV, current);
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:98,代码来源:signal.c
示例7: request_module
/**
* request_module - try to load a kernel module
* @module_name: Name of module
*
* Load a module using the user mode module loader. The function returns
* zero on success or a negative errno code on failure. Note that a
* successful module load does not mean the module did not then unload
* and exit on an error of its own. Callers must check that the service
* they requested is now available not blindly invoke it.
*
* If module auto-loading support is disabled then this function
* becomes a no-operation.
*/
int request_module(const char * module_name)
{
pid_t pid;
int waitpid_result;
sigset_t tmpsig;
int i;
static atomic_t kmod_concurrent = ATOMIC_INIT(0);
#define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
static int kmod_loop_msg;
/* Don't allow request_module() before the root fs is mounted! */
if ( ! current->fs->root )
{
printk(KERN_ERR "request_module[%s]: Root fs not mounted\n",
module_name);
return -EPERM;
}
/* If modprobe needs a service that is in a module, we get a recursive
* loop. Limit the number of running kmod threads to max_threads/2 or
* MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
* would be to run the parents of this process, counting how many times
* kmod was invoked. That would mean accessing the internals of the
* process tables to get the command line, proc_pid_cmdline is static
* and it is not worth changing the proc code just to handle this case.
* KAO.
*/
i = max_threads/2;
if (i > MAX_KMOD_CONCURRENT)
i = MAX_KMOD_CONCURRENT;
atomic_inc(&kmod_concurrent);
if (atomic_read(&kmod_concurrent) > i)
{
if (kmod_loop_msg++ < 5)
printk(KERN_ERR
"kmod: runaway modprobe loop assumed and stopped\n");
atomic_dec(&kmod_concurrent);
return -ENOMEM;
}
pid = kernel_thread(exec_modprobe, (void*) module_name, 0);
if (pid < 0)
{
printk(KERN_ERR "request_module[%s]: fork failed, errno %d\n", module_name, -pid);
atomic_dec(&kmod_concurrent);
return pid;
}
/* Block everything but SIGKILL/SIGSTOP */
spin_lock_irq(¤t->sigmask_lock);
tmpsig = current->blocked;
siginitsetinv(¤t->blocked, sigmask(SIGKILL) | sigmask(SIGSTOP));
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
waitpid_result = waitpid(pid, NULL, __WCLONE);
atomic_dec(&kmod_concurrent);
/* Allow signals again.. */
spin_lock_irq(¤t->sigmask_lock);
current->blocked = tmpsig;
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
if (waitpid_result != pid)
{
printk(KERN_ERR "request_module[%s]: waitpid(%d,...) failed, errno %d\n",
module_name, pid, -waitpid_result);
}
return 0;
}
开发者ID:rroart,项目名称:freevms,代码行数:84,代码来源:kmod.c
示例8: do_ncp_rpc_call
static int do_ncp_rpc_call(struct ncp_server *server, int size,
struct ncp_reply_header* reply_buf, int max_reply_size)
{
struct file *file;
struct inode *inode;
struct socket *sock;
mm_segment_t fs;
int result;
char *start = server->packet;
poll_table wait_table;
struct poll_table_entry entry;
int init_timeout, max_timeout;
int timeout;
int retrans;
int major_timeout_seen;
int acknowledge_seen;
int n;
sigset_t old_set;
unsigned long mask, flags;
/* We have to check the result, so store the complete header */
struct ncp_request_header request =
*((struct ncp_request_header *) (server->packet));
struct ncp_reply_header reply;
file = server->ncp_filp;
inode = file->f_dentry->d_inode;
sock = &inode->u.socket_i;
/* N.B. this isn't needed ... check socket type? */
if (!sock) {
printk(KERN_ERR "ncp_rpc_call: socki_lookup failed\n");
return -EBADF;
}
init_timeout = server->m.time_out;
max_timeout = NCP_MAX_RPC_TIMEOUT;
retrans = server->m.retry_count;
major_timeout_seen = 0;
acknowledge_seen = 0;
spin_lock_irqsave(¤t->sigmask_lock, flags);
old_set = current->blocked;
mask = sigmask(SIGKILL) | sigmask(SIGSTOP);
if (server->m.flags & NCP_MOUNT_INTR) {
/* FIXME: This doesn't seem right at all. So, like,
we can't handle SIGINT and get whatever to stop?
What if we've blocked it ourselves? What about
alarms? Why, in fact, are we mucking with the
sigmask at all? -- r~ */
if (current->sig->action[SIGINT - 1].sa.sa_handler == SIG_DFL)
mask |= sigmask(SIGINT);
if (current->sig->action[SIGQUIT - 1].sa.sa_handler == SIG_DFL)
mask |= sigmask(SIGQUIT);
}
siginitsetinv(¤t->blocked, mask);
recalc_sigpending(current);
spin_unlock_irqrestore(¤t->sigmask_lock, flags);
fs = get_fs();
set_fs(get_ds());
for (n = 0, timeout = init_timeout;; n++, timeout <<= 1) {
/*
DDPRINTK(KERN_DEBUG "ncpfs: %08lX:%02X%02X%02X%02X%02X%02X:%04X\n",
htonl(server->m.serv_addr.sipx_network),
server->m.serv_addr.sipx_node[0],
server->m.serv_addr.sipx_node[1],
server->m.serv_addr.sipx_node[2],
server->m.serv_addr.sipx_node[3],
server->m.serv_addr.sipx_node[4],
server->m.serv_addr.sipx_node[5],
ntohs(server->m.serv_addr.sipx_port));
*/
DDPRINTK(KERN_DEBUG "ncpfs: req.typ: %04X, con: %d, "
"seq: %d",
request.type,
(request.conn_high << 8) + request.conn_low,
request.sequence);
DDPRINTK(KERN_DEBUG " func: %d\n",
request.function);
result = _send(sock, (void *) start, size);
if (result < 0) {
printk(KERN_ERR "ncp_rpc_call: send error = %d\n", result);
break;
}
re_select:
wait_table.nr = 0;
wait_table.entry = &entry;
current->state = TASK_INTERRUPTIBLE;
if (!(file->f_op->poll(file, &wait_table) & POLLIN)) {
int timed_out;
if (timeout > max_timeout) {
/* JEJB/JSP 2/7/94
* This is useful to see if the system is
* hanging */
if (acknowledge_seen == 0) {
printk(KERN_WARNING "NCP max timeout\n");
}
timeout = max_timeout;
//.........这里部分代码省略.........
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:101,代码来源:sock.c
示例9: affixd_thread
int affixd_thread(void *startup)
{
int ret = 0;
struct pollfd fds[2];
__u8 msg[HCI_MAX_MSG_SIZE];
__u8 event[HCI_MAX_EVENT_SIZE];
DBFENTER;
daemonize("affixd");
allow_signal(SIGTERM);
allow_signal(SIGUSR1);
/* Open HCI manager */
fds[0].fd = hci_open_mgr();
if (fds[0].fd < 0) {
ret = fds[0].fd;
fds[1].fd = -1;
goto exit;
}
fds[0].events = POLLIN;
fds[1].fd = hci_open_event();
if (fds[1].fd < 0) {
ret = fds[1].fd;
goto exit;
}
fds[1].events = POLLIN;
up(&exit_sema);
hci_event_mask(fds[1].fd, ALL_EVENTS_MASK &
~(COMMAND_COMPLETE_MASK | COMMAND_STATUS_MASK |
NUMBER_OF_COMPLETE_PACKETS_MASK | FLUSH_OCCURRED_MASK));
module_put(THIS_MODULE);
module_put(THIS_MODULE);
module_put(THIS_MODULE);
module_put(THIS_MODULE);
for (;;) {
ret = hci_poll(fds, 2, -1);
if (ret > 0) {/* we have something */
if ((fds[0].revents | fds[1].revents) & (POLLERR | POLLHUP | POLLNVAL))
break;
if (fds[1].revents) {
if (fds[1].revents & POLLIN) { /* HCI event */
int devnum;
hci_recv_event_any(fds[1].fd, &devnum, event, sizeof(event));
event_handler((void*)event, devnum);
}
}
if (fds[0].revents) {
if (fds[0].revents & POLLIN) {/* MSG */
btsys_recv(fds[0].fd, msg, sizeof(msg), 0);
message_handler((void*)(msg+1));
}
}
}
if (signal_pending(current)) {
DBPRT("Got a signal!!!\n");
// if (sigismember(¤t->pending.signal, SIGUSR1)) {
// sigdelset(¤t->pending.signal, SIGUSR1);
// }
flush_signals(current); // flush pending signals
spin_lock_irq(¤t->sighand->siglock);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
if (mgr_exit)
break;
}
}
//try_module_get(THIS_MODULE);
//try_module_get(THIS_MODULE);
//try_module_get(THIS_MODULE);
//try_module_get(THIS_MODULE);
exit:
if (fds[0].fd >= 0)
hci_close(fds[0].fd);
if (fds[1].fd >= 0)
hci_close(fds[1].fd);
mgr_exit = ret;
up(&exit_sema);
DBFEXIT;
return ret;
}
开发者ID:github188,项目名称:SimpleCode,代码行数:83,代码来源:hci_mgr.c
示例10: irix_sigreturn
asmlinkage void
irix_sigreturn(struct pt_regs *regs)
{
struct sigctx_irix5 __user *context, *magic;
unsigned long umask, mask;
u64 *fregs;
u32 usedfp;
int error, sig, i, base = 0;
sigset_t blocked;
/* Always make any pending restarted system calls return -EINTR */
current_thread_info()->restart_block.fn = do_no_restart_syscall;
if (regs->regs[2] == 1000)
base = 1;
context = (struct sigctx_irix5 __user *) regs->regs[base + 4];
magic = (struct sigctx_irix5 __user *) regs->regs[base + 5];
sig = (int) regs->regs[base + 6];
#ifdef DEBUG_SIG
printk("[%s:%d] IRIX sigreturn(scp[%p],ucp[%p],sig[%d])\n",
current->comm, current->pid, context, magic, sig);
#endif
if (!context)
context = magic;
if (!access_ok(VERIFY_READ, context, sizeof(struct sigctx_irix5)))
goto badframe;
#ifdef DEBUG_SIG
dump_irix5_sigctx(context);
#endif
error = __get_user(regs->cp0_epc, &context->pc);
error |= __get_user(umask, &context->rmask);
mask = 2;
for (i = 1; i < 32; i++, mask <<= 1) {
if (umask & mask)
error |= __get_user(regs->regs[i], &context->regs[i]);
}
error |= __get_user(regs->hi, &context->hi);
error |= __get_user(regs->lo, &context->lo);
error |= __get_user(usedfp, &context->usedfp);
if ((umask & 1) && usedfp) {
fregs = (u64 *) ¤t->thread.fpu;
for(i = 0; i < 32; i++)
error |= __get_user(fregs[i], &context->fpregs[i]);
error |= __get_user(current->thread.fpu.hard.fcr31, &context->fpcsr);
}
/* XXX do sigstack crapola here... XXX */
error |= __copy_from_user(&blocked, &context->sigset, sizeof(blocked)) ? -EFAULT : 0;
if (error)
goto badframe;
sigdelsetmask(&blocked, ~_BLOCKABLE);
spin_lock_irq(¤t->sighand->siglock);
current->blocked = blocked;
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
/*
* Don't let your children do this ...
*/
if (current_thread_info()->flags & TIF_SYSCALL_TRACE)
do_syscall_trace(regs, 1);
__asm__ __volatile__(
"move\t$29,%0\n\t"
"j\tsyscall_exit"
:/* no outputs */
:"r" (®s));
/* Unreached */
badframe:
force_sig(SIGSEGV, current);
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:80,代码来源:irixsig.c
示例11: mtd_blktrans_thread
static int mtd_blktrans_thread(void *arg)
{
struct mtd_blktrans_ops *tr = arg;
struct request_queue *rq = tr->blkcore_priv->rq;
/* we might get involved when memory gets low, so use PF_MEMALLOC */
current->flags |= PF_MEMALLOC | PF_NOFREEZE;
daemonize("%sd", tr->name);
/* daemonize() doesn't do this for us since some kernel threads
actually want to deal with signals. We can't just call
exit_sighand() since that'll cause an oops when we finally
do exit. */
spin_lock_irq(¤t->sighand->siglock);
sigfillset(¤t->blocked);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
#ifdef CONFIG_MOT_WFN473
set_user_nice(current, -20);
#endif
spin_lock_irq(rq->queue_lock);
while (!tr->blkcore_priv->exiting) {
struct request *req;
struct mtd_blktrans_dev *dev;
int res = 0;
DECLARE_WAITQUEUE(wait, current);
req = elv_next_request(rq);
if (!req) {
add_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(rq->queue_lock);
schedule();
remove_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
spin_lock_irq(rq->queue_lock);
continue;
}
dev = req->rq_disk->private_data;
tr = dev->tr;
spin_unlock_irq(rq->queue_lock);
down(&dev->sem);
res = do_blktrans_request(tr, dev, req);
up(&dev->sem);
spin_lock_irq(rq->queue_lock);
end_request(req, res);
}
spin_unlock_irq(rq->queue_lock);
complete_and_exit(&tr->blkcore_priv->thread_dead, 0);
}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:66,代码来源:mtd_blkdevs.c
示例12: handle_signal
/*
* OK, we're invoking a handler
*/
static void
handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs * regs,
unsigned long *newspp, unsigned long frame)
{
struct sigcontext_struct *sc;
struct rt_sigframe *rt_sf;
if (regs->trap == 0x0C00 /* System Call! */
&& ((int)regs->result == -ERESTARTNOHAND ||
((int)regs->result == -ERESTARTSYS &&
!(ka->sa.sa_flags & SA_RESTART))))
regs->result = -EINTR;
/* Set up Signal Frame */
if (ka->sa.sa_flags & SA_SIGINFO) {
/* Put a Real Time Context onto stack */
*newspp -= sizeof(*rt_sf);
rt_sf = (struct rt_sigframe *) *newspp;
if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf)))
goto badframe;
if (__put_user((unsigned long) ka->sa.sa_handler, &rt_sf->uc.uc_mcontext.handler)
|| __put_user(&rt_sf->info, &rt_sf->pinfo)
|| __put_user(&rt_sf->uc, &rt_sf->puc)
/* Put the siginfo */
|| __copy_to_user(&rt_sf->info, info, sizeof(*info))
/* Create the ucontext */
|| __put_user(0, &rt_sf->uc.uc_flags)
|| __put_user(0, &rt_sf->uc.uc_link)
|| __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
|| __put_user(sas_ss_flags(regs->gpr[1]),
&rt_sf->uc.uc_stack.ss_flags)
|| __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
|| __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset))
/* mcontext.regs points to preamble register frame */
|| __put_user((struct pt_regs *)frame, &rt_sf->uc.uc_mcontext.regs)
|| __put_user(sig, &rt_sf->uc.uc_mcontext.signal))
goto badframe;
} else {
/* Put another sigcontext on the stack */
*newspp -= sizeof(*sc);
sc = (struct sigcontext_struct *) *newspp;
if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
goto badframe;
if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
|| __put_user(oldset->sig[0], &sc->oldmask)
#if _NSIG_WORDS > 1
|| __put_user(oldset->sig[1], &sc->_unused[3])
#endif
|| __put_user((struct pt_regs *)frame, &sc->regs)
|| __put_user(sig, &sc->signal))
goto badframe;
}
if (ka->sa.sa_flags & SA_ONESHOT)
ka->sa.sa_handler = SIG_DFL;
if (!(ka->sa.sa_flags & SA_NODEFER)) {
spin_lock_irq(¤t->sigmask_lock);
sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
sigaddset(¤t->blocked,sig);
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
}
return;
badframe:
#if DEBUG_SIG
printk("badframe in handle_signal, regs=%p frame=%lx newsp=%lx\n",
regs, frame, *newspp);
printk("sc=%p sig=%d ka=%p info=%p oldset=%p\n", sc, sig, ka, info, oldset);
#endif
do_exit(SIGSEGV);
}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:81,代码来源:signal.c
示例13: sys_sigreturn
/*
* Do a signal return; undo the signal stack.
*/
long sys_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7, unsigned long r8,
struct pt_regs *regs)
{
struct sigcontext_struct *sc, sigctx;
struct sigregs *sr;
long ret;
elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */
sigset_t set;
unsigned long prevsp;
sc = (struct sigcontext_struct *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
goto badframe;
set.sig[0] = sigctx.oldmask;
#if _NSIG_WORDS > 1
set.sig[1] = sigctx._unused[3];
#endif
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(¤t->sigmask_lock);
current->blocked = set;
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
sc++; /* Look at next sigcontext */
if (sc == (struct sigcontext_struct *)(sigctx.regs)) {
/* Last stacked signal - restore registers */
sr = (struct sigregs *) sigctx.regs;
if (regs->msr & MSR_FP )
giveup_fpu(current);
if (copy_from_user(saved_regs, &sr->gp_regs,
sizeof(sr->gp_regs)))
goto badframe;
saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
| (saved_regs[PT_MSR] & MSR_USERCHANGE);
saved_regs[PT_SOFTE] = regs->softe;
memcpy(regs, saved_regs, GP_REGS_SIZE);
if (copy_from_user(current->thread.fpr, &sr->fp_regs,
sizeof(sr->fp_regs)))
goto badframe;
ret = regs->result;
} else {
/* More signals to go */
regs->gpr[1] = (unsigned long)sc - __SIGNAL_FRAMESIZE;
if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
goto badframe;
sr = (struct sigregs *) sigctx.regs;
regs->gpr[3] = ret = sigctx.signal;
regs->gpr[4] = (unsigned long) sc;
regs->link = (unsigned long) &sr->tramp;
regs->nip = sigctx.handler;
if (get_user(prevsp, &sr->gp_regs[PT_R1])
|| put_user(prevsp, (unsigned long *) regs->gpr[1]))
goto badframe;
}
return ret;
badframe:
do_exit(SIGSEGV);
}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:68,代码来源:signal.c
示例14: ERR_PTR
//.........这里部分代码省略.........
p->task_works = NULL;
/*
* Make it visible to the rest of the system, but dont wake it up yet.
* Need tasklist lock for parent etc handling!
*/
write_lock_irq(&tasklist_lock);
/* CLONE_PARENT re-uses the old parent */
if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
p->real_parent = current->real_parent;
p->parent_exec_id = current->parent_exec_id;
} else {
p->real_parent = current;
p->parent_exec_id = current->self_exec_id;
}
spin_lock(¤t->sighand->siglock);
/*
* Copy seccomp details explicitly here, in case they were changed
* before holding sighand lock.
*/
copy_seccomp(p);
/*
* Process group and session signals need to be delivered to just the
* parent before the fork or both the parent and the child after the
* fork. Restart if a signal comes in before we add the new process to
* it's process group.
* A fatal signal pending means that current will exit, so the new
* thread can't slip out of an OOM kill (or normal SIGKILL).
*/
recalc_sigpending();
if (signal_pending(current)) {
spin_unlock(¤t->sighand->siglock);
write_unlock_irq(&tasklist_lock);
retval = -ERESTARTNOINTR;
goto bad_fork_free_pid;
}
if (likely(p->pid)) {
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
init_task_pid(p, PIDTYPE_PID, pid);
if (thread_group_leader(p)) {
init_task_pid(p, PIDTYPE_PGID, task_pgrp(current));
init_task_pid(p, PIDTYPE_SID, task_session(current));
if (is_child_reaper(pid)) {
ns_of_pid(pid)->child_reaper = p;
p->signal->flags |= SIGNAL_UNKILLABLE;
}
p->signal->leader_pid = pid;
p->signal->tty = tty_kref_get(current->signal->tty);
list_add_tail(&p->sibling, &p->real_parent->children);
list_add_tail_rcu(&p->tasks, &init_task.tasks);
attach_pid(p, PIDTYPE_PGID);
attach_pid(p, PIDTYPE_SID);
__this_cpu_inc(process_counts);
} else {
current->signal->nr_threads++;
atomic_inc(¤t->signal->live);
atomic_inc(¤t->signal->sigcnt);
list_add_tail_rcu(&p->thread_group,
开发者ID:GAXUSXX,项目名称:G935FGaXusKernel2,代码行数:67,代码来源:fork.c
示例15: handle_signal
static int
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs)
{
int ret;
#ifdef DEBUG_SIG
printk("handle_signal pid:%d sig:%lu rip:%lx rsp:%lx regs=%p\n",
current->pid, sig,
regs->rip, regs->rsp, regs);
#endif
/* Are we from a system call? */
if ((long)regs->orig_rax >= 0) {
/* If so, check system call restarting.. */
switch (regs->rax) {
case -ERESTART_RESTARTBLOCK:
case -ERESTARTNOHAND:
regs->rax = -EINTR;
break;
case -ERESTARTSYS:
if (!(ka->sa.sa_flags & SA_RESTART)) {
regs->rax = -EINTR;
break;
}
/* fallthrough */
case -ERESTARTNOINTR:
regs->rax = regs->orig_rax;
regs->rip -= 2;
break;
}
}
/*
* If TF is set due to a debugger (PT_DTRACE), clear the TF
* flag so that register information in the sigcontext is
* correct.
*/
if (unlikely(regs->eflags & TF_MASK)) {
if (likely(current->ptrace & PT_DTRACE)) {
current->ptrace &= ~PT_DTRACE;
regs->eflags &= ~TF_MASK;
}
}
#ifdef CONFIG_IA32_EMULATION
if (test_thread_flag(TIF_IA32)) {
if (ka->sa.sa_flags & SA_SIGINFO)
ret = ia32_setup_rt_frame(sig, ka, info, oldset, regs);
else
ret = ia32_setup_frame(sig, ka, oldset, regs);
} else
#endif
ret = setup_rt_frame(sig, ka, info, oldset, regs);
if (ret == 0) {
spin_lock_irq(¤t->sighand->siglock);
sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
if (!(ka->sa.sa_flags & SA_NODEFER))
sigaddset(¤t->blocked,sig);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
}
return ret;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:67,代码来源:signal.c
示例16: cachemiss_thread
static int cachemiss_thread (void *data)
{
tux_req_t *req;
struct k_sigaction *ka;
DECLARE_WAITQUEUE(wait, current);
iothread_t *iot = data;
int nr = iot->ti->cpu, wake_up;
Dprintk("iot %p/%p got started.\n", iot, current);
drop_permissions();
spin_lock(&iot->async_lock);
iot->threads++;
sprintf(current->comm, "async IO %d/%d", nr, iot->threads);
spin_lock_irq(¤t->sighand->siglock);
ka = current->sighand->action + SIGCHLD-1;
ka->sa.sa_handler = SIG_IGN;
siginitsetinv(¤t->blocked, sigmask(SIGCHLD));
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
spin_unlock(&iot->async_lock);
#ifdef CONFIG_SMP
{
cpumask_t mask;
if (cpu_isset(nr, cpu_online_map)) {
cpus_clear(mask);
cpu_set(nr, mask);
set_cpus_allowed(current, mask);
}
}
#endif
add_wait_queue_exclusive(&iot->async_sleep, &wait);
for (;;) {
while (!list_empty(&iot->async_queue) &&
(req = get_cachemiss(iot))) {
if (!req->atom_idx) {
add_tux_atom(req, flush_request);
add_req_to_workqueue(req);
continue;
}
tux_schedule_atom(req, 1);
if (signal_pending(current))
flush_all_signals();
}
if (signal_pending(current))
flush_all_signals();
if (!list_empty(&iot->async_queue))
continue;
if (iot->shutdown) {
Dprintk("iot %p/%p got shutdown!\n", iot, current);
break;
}
__set_current_state(TASK_INTERRUPTIBLE);
if (list_empty(&iot->async_queue)) {
Dprintk("iot %p/%p going to sleep.\n", iot, current);
schedule();
Dprintk("iot %p/%p got woken up.\n", iot, current);
}
__set_current_state(TASK_RUNNING);
}
remove_wait_queue(&iot->async_sleep, &wait);
wake_up = 0;
spin_lock(&iot->async_lock);
if (!--iot->threads)
wake_up = 1;
spin_unlock(&iot->async_lock);
Dprintk("iot %p/%p has finished shutdown!\n", iot, current);
if (wake_up) {
Dprintk("iot %p/%p waking up master.\n", iot, current);
wake_up(&iot->wait_shutdown);
}
return 0;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:84,代码来源:cachemiss.c
示例17: p9_client_rpc
static struct p9_req_t *
p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
{
va_list ap;
int tag, err;
struct p9_req_t *req;
unsigned long flags;
int sigpending;
int flushed = 0;
P9_DPRINTK(P9_DEBUG_MUX, "client %p op %d\n", c, type);
if (c->status != Connected)
return ERR_PTR(-EIO);
if (signal_pending(current)) {
sigpending = 1;
clear_thread_flag(TIF_SIGPENDING);
} else
sigpending = 0;
tag = P9_NOTAG;
if (type != P9_TVERSION) {
tag = p9_idpool_get(c->tagpool);
if (tag < 0)
return ERR_PTR(-ENOMEM);
}
req = p9_tag_alloc(c, tag);
if (IS_ERR(req))
return req;
/* marshall the data */
p9pdu_prepare(req->tc, tag, type);
va_start(ap, fmt);
err = p9pdu_vwritef(req->tc, c->dotu, fmt, ap);
va_end(ap);
p9pdu_finalize(req->tc);
err = c->trans_mod->request(c, req);
if (err < 0) {
c->status = Disconnected;
goto reterr;
}
/* if it was a flush we just transmitted, return our tag */
if (type == P9_TFLUSH)
return req;
again:
P9_DPRINTK(P9_DEBUG_MUX, "wait %p tag: %d\n", req->wq, tag);
err = wait_event_interruptible(*req->wq,
req->status >= REQ_STATUS_RCVD);
P9_DPRINTK(P9_DEBUG_MUX, "wait %p tag: %d returned %d (flushed=%d)\n",
req->wq, tag, err, flushed);
if (req->status == REQ_STATUS_ERROR) {
P9_DPRINTK(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err);
err = req->t_err;
} else if (err == -ERESTARTSYS && flushed) {
P9_DPRINTK(P9_DEBUG_MUX, "flushed - going again\n");
goto again;
} else if (req->status == REQ_STATUS_FLSHD) {
P9_DPRINTK(P9_DEBUG_MUX, "flushed - erestartsys\n");
err = -ERESTARTSYS;
}
if ((err == -ERESTARTSYS) && (c->status == Connected) && (!flushed)) {
P9_DPRINTK(P9_DEBUG_MUX, "flushing\n");
spin_lock_irqsave(&c->lock, flags);
if (req->status == REQ_STATUS_SENT)
req->status = REQ_STATUS_FLSH;
spin_unlock_irqrestore(&c->lock, flags);
sigpending = 1;
flushed = 1;
clear_thread_flag(TIF_SIGPENDING);
if (c->trans_mod->cancel(c, req)) {
err = p9_client_flush(c, req);
if (err == 0)
goto again;
}
}
if (sigpending) {
spin_lock_irqsave(¤t->sighand->siglock, flags);
recalc_sigpending();
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
}
if (err < 0)
goto reterr;
err = p9_check_errors(c, req);
if (!err) {
P9_DPRINTK(P9_DEBUG_MUX, "exit: client %p op %d\n", c, type);
return req;
}
reterr:
P9_DPRINTK(P9_DEBUG_MUX, "exit: client %p op %d error: %d\n", c, type,
//.........这里部分代码省略.........
开 |
请发表评论