Re: [PATCH 2/2] Notify container-init parent a 'reboot' occured

From: Daniel Lezcano
Date: Sat Aug 13 2011 - 10:41:17 EST


On 08/13/2011 02:19 AM, Matt Helsley wrote:
> On Thu, Aug 11, 2011 at 10:24:01PM +0200, Daniel Lezcano wrote:
>> When the reboot syscall is called and the pid namespace where the calling
>> process belongs to is not from the init pidns, we send a SIGCHLD with CLD_REBOOTED
>> to the parent of this pid namespace.
> Shouldn't we honor the exit_signal set via clone() here rather than
> hardcode SIGCHLD? More below...

Hmm, I don't think so, that does not really make sense.

[ ... ]

>> +void do_notify_parent_cldreboot(struct task_struct *tsk, int why, char *buffer)
>> +{
>> + struct siginfo info = { };
>> + struct task_struct *parent;
>> + struct sighand_struct *sighand;
>> + unsigned long flags;
>> +
>> + if (tsk->ptrace)
>> + parent = tsk->parent;
>> + else {
>> + tsk = tsk->group_leader;
>> + parent = tsk->real_parent;
>> + }
>> +
>> + info.si_signo = SIGCHLD;
> should this be:
>
> info.si_signo = tsk->exit_signal == -1 ? SIGCHLD : tsk->exit_signal;


No, because this code is always called for SIGHLD.
The userspace will receive this signal with CLD_REBOOT if it sets the
SA_CLDREBOOT flag option which is not set by default.

>> + info.si_errno = 0;
>> + info.si_status = why;
>> +
>> + rcu_read_lock();
>> + info.si_pid = task_pid_nr_ns(tsk, parent->nsproxy->pid_ns);
>> + info.si_uid = __task_cred(tsk)->uid;
>> + rcu_read_unlock();
>> +
>> + info.si_utime = cputime_to_clock_t(tsk->utime);
>> + info.si_stime = cputime_to_clock_t(tsk->stime);
>> +
>> + info.si_code = CLD_REBOOTED;
>> +
>> + sighand = parent->sighand;
>> + spin_lock_irqsave(&sighand->siglock, flags);
>> + if (sighand->action[SIGCHLD-1].sa.sa_handler != SIG_IGN &&
>> + sighand->action[SIGCHLD-1].sa.sa_flags & SA_CLDREBOOT)
>> + __group_send_sig_info(SIGCHLD, &info, parent);
> (with corresponding changes above...)
>
>> + /*
>> + * Even if SIGCHLD is not generated, we must wake up wait4 calls.
>> + */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/