2006-12-14 00:28:36

by Daniel Forrest

[permalink] [raw]
Subject: Processes with hidden PID files in /proc

Hopefully someone can give me a quick answer...

Yesterday I discovered some processes that had a PPID which was not
shown as a running process by "ps". Also an "ls /proc" did not show
that PPID.

I've Googled on this enough to find out that these are Linux threads,
that "ps -m" will show them, that "ls -a /proc" will show /proc/.PPID,
etc, but I'm still wondering what exact sequence of system calls will
create a process like this?

I'm trying to file a bug report for another piece of software and I
would like to make a simple test program that shows this situation.

Thanks,

--
Daniel K. Forrest Laboratory for Molecular and
[email protected] Computational Genomics
(608) 262 - 9479 University of Wisconsin, Madison


2006-12-14 01:21:52

by Bernd Eckenfels

[permalink] [raw]
Subject: Re: Processes with hidden PID files in /proc

In article <[email protected]> you wrote:
> I've Googled on this enough to find out that these are Linux threads,
> that "ps -m" will show them, that "ls -a /proc" will show /proc/.PPID,
> etc, but I'm still wondering what exact sequence of system calls will
> create a process like this?

clone(2) can be used to create a thread in a new thread group. If that
thread forks, the resulting child has the (invisible) thread group as parent
pid.

Gruss
Bernd

2006-12-14 17:11:39

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Processes with hidden PID files in /proc


>Yesterday I discovered some processes that had a PPID which was not
>shown as a running process by "ps". Also an "ls /proc" did not show
>that PPID.
>
>I've Googled on this enough to find out that these are Linux threads,
>that "ps -m" will show them, that "ls -a /proc" will show /proc/.PPID,
>etc, but I'm still wondering what exact sequence of system calls will
>create a process like this?

It's all there:

18:10 ichi:/proc/3689 # l exe
lrwxrwxrwx 1 root root 0 Dec 14 08:02 exe -> /usr/sbin/named
18:10 ichi:/proc/3689 # l task
total 0
dr-xr-xr-x 6 named named 0 Dec 14 18:09 .
dr-xr-xr-x 5 named named 0 Dec 14 08:02 ..
dr-xr-xr-x 4 named named 0 Dec 14 18:09 3689
dr-xr-xr-x 4 named named 0 Dec 14 18:09 3690
dr-xr-xr-x 4 named named 0 Dec 14 18:09 3691
dr-xr-xr-x 4 named named 0 Dec 14 18:09 3692
18:10 ichi:/proc/3689 # l -d ../3692
dr-xr-xr-x 5 named named 0 Dec 14 18:09 ../3692
18:10 ichi:/proc/3689 # l .. | grep 3692

W.W.W.W.W.

Only "processes" are returned by readdir() on /proc, but every "thread"
(LWP) is still accessible.

-`J'
--