> > Anyway, re-parenting to swapper breaks pstree, it doesn't show kernel> > threads. And if ->parent == /sbin/init, we can't remove us from ->children> > (unless we forbid sub-thread-of-init exec). So the only safe change is> > set ->exit_state = -1.> > Yes. We certainly need ->exit_state = -1.> Earlier I had forgotten about second the use of ->children to update> the parent pointer of processes when their parent exits.> > There is a practical question how much we care about pstree being> confused (I assume it doesn't crash). If this is just a confusion> issue then I say go for it. PPID == 0 is a very legitimate way to say> the kernel is the parent process.

No, it doesn't crash. It just doesn't show kernel threads (ps ax is OK).I didn't look into the sources, but I guess the reason is that pstreeassumes that the "root" of the tree is "pid == 1" process.

I personally think this is acceptable (and Roland seems to think the same).Still, to be safe, I'll break this into 2 patches, the first one sets->exit_state, the second re-parents to swapper.

In fact, we can do some odd things to make pstree happy. We need ->parentonly because /proc needs some ->parent fields. But I'd prefer to avoidthese hacks.

Still, it is sad that we can't have additional flags for kernel_thread().However, I agree with your and Roland's objections.