Re: [RFC, PATCH 1/3] introduce SYS_CLONE_MASK

Jan Engelhardt
2007-04-10T18:32:23Z

On Apr 10 2007 17:47, Jan Engelhardt wrote:
>On Apr 8 2007 20:57, Oleg Nesterov wrote:
>>
>>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.
>
>Then we have to fix pstree and all that. (In fact, I'm
>trying to patch `ps f` to DTRT ;p)

Done that and the result is that `ps afwx` now looks like:

PID TTY STAT TIME COMMAND
2722 ? S 0:00 [lockd]
2721 ? S< 0:00 [rpciod/0]
749 ? S< 0:00 [ata_aux]
748 ? S< 0:00 [ata/0]
496 ? S< 0:00 [xfssyncd]
495 ? S< 0:00 [xfsbufd]
484 ? S< 0:00 [xfsdatad/0]
482 ? S< 0:00 [xfslogd/0]
427 ? S< 0:00 [scsi_eh_0]
204 ? S< 0:00 [kpsmoused]
110 ? S< 0:00 [aio/0]
109 ? S< 0:00 [kswapd0]
108 ? S 0:00 [pdflush]
107 ? S 0:00 [pdflush]
85 ? S< 0:00 [kseriod]
21 ? S< 0:00 [kacpid]
20 ? S< 0:00 [kblockd/0]
5 ? S< 0:00 [kthread]
4 ? S< 0:00 [khelper]
3 ? S< 0:00 [events/0]
2 ? SN 0:00 [ksoftirqd/0]
1 ? Ss 0:02 init [3]
537 ? S<s 0:02 \_ /sbin/udevd --daemon
1600 ? Ss 0:00 \_ /usr/bin/dbus-daemon --system
1692 ? Ss 0:00 \_ /sbin/acpid
1923 ? Ss 0:00 \_ /sbin/resmgrd
1985 ? Ss 0:00 \_ /usr/sbin/polkitd
2014 ? Ss 0:02 \_ /usr/sbin/hald --daemon=yes
2022 ? S 0:00 | \_ hald-runner
2051 ? S 0:00 | \_ hald-addon-keyboard: listening on /d
2061 ? S 0:00 | \_ hald-addon-keyboard: listening on /d
2085 ? S 0:00 | \_ hald-addon-acpi: listening on acpid
2086 ? S 0:00 | \_ hald-addon-storage: polling /dev/hdc
2601 ? Ss 0:00 \_ /sbin/syslog-ng
2602 ? Ss 0:00 \_ /usr/sbin/sshd -o PidFile=/var/run/sshd.init
2607 ? Ss 0:00 \_ /sbin/klogd -c 1 -x -x
2617 ? Ss 0:00 \_ /usr/sbin/gpm -m /dev/input/mice -t ps2
2623 ? Ss 0:00 \_ /sbin/portmap
2634 ? Ss 0:00 \_ login -- root
2688 tty1 Ss+ 0:00 | \_ -bash
2635 ? Ss 0:00 \_ login -- jengelh
2733 tty2 Ss 0:00 | \_ -bash
2850 tty2 R+ 0:00 | \_ ./ps afwx
2636 tty3 Ss+ 0:00 \_ /sbin/mingetty tty3
2637 tty4 Ss+ 0:00 \_ /sbin/mingetty tty4
2638 tty5 Ss+ 0:00 \_ /sbin/mingetty tty5
2651 tty6 Ss+ 0:00 \_ /sbin/mingetty tty6

Except for the unsorted bunch before process 1, this looks good, and
of course it only took a single line change.

Index: procps-3.2.7/ps/display.c
===================================================================
--- procps-3.2.7.orig/ps/display.c
+++ procps-3.2.7/ps/display.c
@@ -482,7 +482,7 @@ static void show_tree(const int self, co
more_children = 0;
else
if(processes[i+1]->ppid != self_pid) more_children = 0;
- if(self_pid==1 && ADOPTED(processes[i]) && forest_type!='u')
+ if(ADOPTED(processes[i]) && forest_type!='u')
show_tree(i++, n, level, more_children);
else
show_tree(i++, n, level+1, more_children);

Jan
--