Beispiel #1
0
int ckpt_restore_sigpending(struct sigpending *sigpending, int shared, ckpt_desc_t desc)
{
    int i;
    ckpt_sigqueue_t queue;
    ckpt_sigpending_t pending;
    struct siginfo *info = &queue.info;

    if (ckpt_read(desc, &pending, sizeof(ckpt_sigpending_t)) != sizeof(ckpt_sigpending_t)) {
        log_err("failed to get sigpending");
        return -EIO;
    }

    for (i = 0; i < pending.count; i++) {
        if (ckpt_read(desc, &queue, sizeof(ckpt_sigqueue_t)) != sizeof(ckpt_sigqueue_t)) {
            log_err("failed to get sigqueue");
            return -EIO;
        }

        if (shared) {
            read_lock((rwlock_t *)TASKLIST_LOCK);
            group_send_sig_info(info->si_signo, info, current);
            read_unlock((rwlock_t *)TASKLIST_LOCK);
        } else
            send_sig_info(info->si_signo, info, current);
    }

    spin_lock_irq(&current->sighand->siglock);
    sigorsets(&sigpending->signal, &sigpending->signal, &pending.signal);
    recalc_sigpending();
    spin_unlock_irq(&current->sighand->siglock);
    return 0;
}
Beispiel #2
0
void warn_if_big_fd(unsigned int fd, struct task_struct *dst_tsk)
{
	int sleep_ms;
	pid_t cur_tid;
	pid_t dst_pid;

	if ((fd < fdleak_dbg_bigfd) || (current->flags & PF_KTHREAD)) {
		/* Do nothing if fd is small or not in user-space process */
		return;
	}

	sleep_ms = 0;
	cur_tid = task_pid_nr(current);
	dst_pid = task_tgid_nr(dst_tsk);

	if (is_android_exe(current)) {
		struct siginfo info;
		info.si_signo = SIGUSR1;
		/*
		 * The following 4 fields are severely hacked
		 */
		info.si_errno = fd;
		info.si_code = SI_KERNEL;
		info.si_uid = (uid_t)dst_pid;
		info.si_pid = cur_tid;
		/*
		 * Assume there's at least one thread waiting for
		 * SIGUSR1 with SI_KERNEL si_code, that may dump
		 * the backtrace of "current" task and then send
		 * SIGCONT back as soon as possible.
		 */
		if (!group_send_sig_info(SIGUSR1, &info, current)) {
			/* Wait at most 100 milli-seconds */
			sleep_ms = 100;
		}
	} else if (!notify_helsmond_of_big_fd(fd, cur_tid, dst_pid)) {
		/* Slower because of added IPC. Use a longer timeout */
		sleep_ms = 200;
	}

	if (sleep_ms > 0) {
		/* Wait for dumping current thread's stack */
		msleep_interruptible(sleep_ms);
	}
}