Skip to contentSkip to conversation

copy_process: remove the unneeded clear_tsk_thread_flag(TIF_SIGPENDING)

PATCH In review Oleg Nesterov 2 participants 3 messages Apr 27, 2009 – Apr 28, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 copy_process: remove the unneeded clear_tsk_thread_flag(TIF_SIGPENDING)

The forked child can have TIF_SIGPENDING if it was copied from parent's ti->flags. But this is harmless and actually almost never happens, because copy_process() can't succeed if signal_pending() == T.

kernel/fork.c renamed from kernel/fork.c~FORK_SIGPENDING +0 -1
@@ -1027,7 +1027,6 @@ static struct task_struct *copy_process(
 	p->vfork_done = NULL;
 	spin_lock_init(&p->alloc_lock);
 
-	clear_tsk_thread_flag(p, TIF_SIGPENDING);
 	init_sigpending(&p->pending);
 
 	p->utime = cputime_zero;
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines

The forked child can have TIF_SIGPENDING if it was copied from parent's ti->flags. But this is harmless and actually almost never happens, because copy_process() can't succeed if signal_pending() == T.

When it does happen, it's actually improper to clear it. In a CLONE_THREAD case, the pending signals might include shared_pending signals that the child too should take. (Arguably there is no way to notice, since the parent thread will be racing to dequeue the same signals.)

Thanks,
Roland

#2 lore raw
Quoted 11 lines · Roland McGrath
Quoted 3 lines

The forked child can have TIF_SIGPENDING if it was copied from parent's ti->flags. But this is harmless and actually almost never happens, because copy_process() can't succeed if signal_pending() == T.

When it does happen, it's actually improper to clear it. In a CLONE_THREAD case, the pending signals might include shared_pending signals that the child too should take. (Arguably there is no way to notice, since the parent thread will be racing to dequeue the same signals.)

Yes, sure. Now I see the changelog is not very clear.

I meant, it is possible that the parent has the false TIF_SIGPENDING which is cleared later by recalc_sigpending(). In this case it is correct to do clear_tsk_thread_flag(p, TIF_SIGPENDING), but this almost never happens.

Oleg.