Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

/proc/6656/cmdline: No such file or directory

117 views
Skip to first unread message

Hongyi Zhao

unread,
May 31, 2015, 1:52:02 AM5/31/15
to
Hi all,

When I running my script, sometimes I noticed the errors similar to the
following:

/proc/6656/cmdline: No such file or directory

Any hints on this issue?

Regards
--
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Daniel Doron

unread,
May 31, 2015, 10:34:22 AM5/31/15
to
maybe there is no process 6656 or by the time your script looks for it it has died? show us your script...

Kenny McCormack

unread,
May 31, 2015, 11:19:32 AM5/31/15
to
In article <mke7hv$375$1...@aspen.stu.neva.ru>,
Hongyi Zhao <hongy...@gmail.com> wrote:
>Hi all,
>
>I am thinking of a number between 1 and 10.
>
>Any guesses as to what it might be?
>
>Regards

I guess 7.

--
(The Republican mind, in a nutshell)
You believe things that are incomprehensible, inconsistent, impossible
because we have commanded you to believe them; go then and do what is
unjust because we command it. Such people show admirable reasoning. Truly,
whoever is able to make you absurd is able to make you unjust. If the
God-given understanding of your mind does not resist a demand to believe
what is impossible, then you will not resist a demand to do wrong to that
God-given sense of justice in your heart. As soon as one faculty of your
soul has been dominated, other faculties will follow as well. And from this
derives all those crimes of religion which have overrun the world.

(Alternative condensed translation)
"Those who can make you believe absurdities, can make you commit atrocities".

Kaz Kylheku

unread,
May 31, 2015, 11:28:39 AM5/31/15
to
On 2015-05-31, Hongyi Zhao <hongy...@gmail.com> wrote:
> Hi all,
>
> When I running my script, sometimes I noticed the errors similar to the
> following:
>
> /proc/6656/cmdline: No such file or directory
>
> Any hints on this issue?

TOCTOTOU race condition? Are you extracting a PID from the output of ps, and then
using it to explore /proc?

http://en.wikipedia.org/wiki/Time_of_check_to_time_of_use

Here, the "check" is the detection of the existence of a process, obtaining a PID.
And "use" is the use of that PID to access properties of the process.

By the time ps terminates, some of the processes which it listed may have
terminated.

Worse, the PIDs which were observed can already be recycled to new processes,
unrelated to the old: which means the /proc/<pid> which you access exists, but is
not the process you think it is.

This is going to be rare, but not impossible: it depends on how wide the PID
space is, how fast the macine is generating new processes, and how these
parameters relate to the sampling-to-use delay in your script. If the script hits
some unusual delay (stuck on some procedure that involves a network transaction, say)
it becomes more likely.

Thomas 'PointedEars' Lahn

unread,
May 31, 2015, 12:06:49 PM5/31/15
to
Hongyi Zhao wrote:

> When I running my script, sometimes I noticed the errors similar to the
> following:
>
> /proc/6656/cmdline: No such file or directory
>
> Any hints on this issue?

I had not thought it possible that your questions could become more silly,
but here are you, proving me wrong.

--
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Hongyi Zhao

unread,
Jun 1, 2015, 4:58:55 AM6/1/15
to
On Sun, 31 May 2015 15:28:33 +0000, Kaz Kylheku wrote:

> TOCTOTOU race condition? Are you extracting a PID from the output of ps,
> and then using it to explore /proc?

I use pstree to obtain the total processes issued by curl like this:

until [[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
egrep '^curl.*-sL.*debian' |egrep -v '^egrep'|wc -l ) -lt
$maxconn ]] &&
[[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
egrep "^curl.*-sL.*${mirror[idx]}" | wc -l ) -lt $connpersrv
]]; do
...
done

Regards
>
> http://en.wikipedia.org/wiki/Time_of_check_to_time_of_use
>
> Here, the "check" is the detection of the existence of a process,
> obtaining a PID.
> And "use" is the use of that PID to access properties of the process.
>
> By the time ps terminates, some of the processes which it listed may
> have terminated.

Kaz Kylheku

unread,
Jun 1, 2015, 12:03:39 PM6/1/15
to
On 2015-06-01, Hongyi Zhao <hongy...@gmail.com> wrote:
> On Sun, 31 May 2015 15:28:33 +0000, Kaz Kylheku wrote:
>
>> TOCTOTOU race condition? Are you extracting a PID from the output of ps,
>> and then using it to explore /proc?
>
> I use pstree to obtain the total processes issued by curl like this:
>
> until [[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
> egrep '^curl.*-sL.*debian' |egrep -v '^egrep'|wc -l ) -lt
> $maxconn ]] &&
> [[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
> egrep "^curl.*-sL.*${mirror[idx]}" | wc -l ) -lt $connpersrv
> ]]; do
> ...
> done

What utility you use to obtain the list of processes doesn't matter.
By the time you use the information, it is out of date.

Barry Margolin

unread,
Jun 1, 2015, 12:32:23 PM6/1/15
to
In article <mkh6sc$o9l$1...@aspen.stu.neva.ru>,
Hongyi Zhao <hongy...@gmail.com> wrote:

> On Sun, 31 May 2015 15:28:33 +0000, Kaz Kylheku wrote:
>
> > TOCTOTOU race condition? Are you extracting a PID from the output of ps,
> > and then using it to explore /proc?
>
> I use pstree to obtain the total processes issued by curl like this:
>
> until [[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
> egrep '^curl.*-sL.*debian' |egrep -v '^egrep'|wc -l ) -lt
> $maxconn ]] &&
> [[ $( pstree -al $$ | sed -e 's/^[ `|-]*//g' |
> egrep "^curl.*-sL.*${mirror[idx]}" | wc -l ) -lt $connpersrv
> ]]; do
> ...
> done

The code in pstree is probably something like:

Step 1: Get all children of PID X
Step 2: For each child:
Step 2a: Get its command line from /proc/PID/cmdline and display it
Step 2b: Recurse to show all its children

If one of the children exits between step 1 and the corresponding step
2a, you'll get that warning.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Stephane Chazelas

unread,
Jun 1, 2015, 12:35:10 PM6/1/15
to
2015-06-01 16:03:29 +0000, Kaz Kylheku:
Note that the problem here happens within pstree itself, causing
it to abort which could be considered as a bug.

I can reproduce it fairly easily after a few attempts at:

$ bash -c 'for ((i=0;i<1000;i++)); do sleep 0.02 & done; pstree -al "$$"'
/proc/8125/cmdline: No such file or directory

--
Stephane

Hongyi Zhao

unread,
Jun 1, 2015, 7:26:26 PM6/1/15
to
On Mon, 01 Jun 2015 12:32:18 -0400, Barry Margolin wrote:

> The code in pstree is probably something like:
>
> Step 1: Get all children of PID X Step 2: For each child:
> Step 2a: Get its command line from /proc/PID/cmdline and display it
> Step 2b: Recurse to show all its children
>
> If one of the children exits between step 1 and the corresponding step
> 2a, you'll get that warning.

How to workaround this issue? I've tried to use pgrep. But the
difficulty of recursing to show all children of PID X by using pgrep let
me select the pstree for this job.

Regards

Hongyi Zhao

unread,
Jun 1, 2015, 7:52:20 PM6/1/15
to
On Mon, 01 Jun 2015 23:26:23 +0000, Hongyi Zhao wrote:

> On Mon, 01 Jun 2015 12:32:18 -0400, Barry Margolin wrote:
>
>> The code in pstree is probably something like:
>>
>> Step 1: Get all children of PID X Step 2: For each child:
>> Step 2a: Get its command line from /proc/PID/cmdline and display it
>> Step 2b: Recurse to show all its children
>>
>> If one of the children exits between step 1 and the corresponding step
>> 2a, you'll get that warning.
>
> How to workaround this issue? I've tried to use pgrep. But the
> difficulty of recursing to show all children of PID X by using pgrep let
> me select the pstree for this job.
>
> Regards

And another issue:

It seems the the pstree have different implementations by different
authors, say, the following one:

http://www.thp.uni-duisburg.de/pstree/

is not the same as the one installed on my Debian wheezy box:

$ pstree --version
pstree (PSmisc) 22.19
Copyright (C) 1993-2009 Werner Almesberger and Craig Small

PSmisc comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under
the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING.

Barry Margolin

unread,
Jun 1, 2015, 8:02:00 PM6/1/15
to
In article <20150601163...@chaz.gmail.com>,
When I posted my explanation, I assumed it just printed a warning and
went on to the next process. Aborting the whole thing is just totally
wrong.

That's too bad.

Hongyi Zhao

unread,
Jun 1, 2015, 8:14:22 PM6/1/15
to
On Mon, 01 Jun 2015 20:01:57 -0400, Barry Margolin wrote:

> When I posted my explanation, I assumed it just printed a warning and
> went on to the next process. Aborting the whole thing is just totally
> wrong.
>
> That's too bad.

I've reported this issue to the developer of psmisc package.

Regards

Dan Espen

unread,
Jun 1, 2015, 9:30:00 PM6/1/15
to
Hongyi Zhao <hongy...@gmail.com> writes:

> On Mon, 01 Jun 2015 12:32:18 -0400, Barry Margolin wrote:
>
>> The code in pstree is probably something like:
>>
>> Step 1: Get all children of PID X Step 2: For each child:
>> Step 2a: Get its command line from /proc/PID/cmdline and display it
>> Step 2b: Recurse to show all its children
>>
>> If one of the children exits between step 1 and the corresponding step
>> 2a, you'll get that warning.
>
> How to workaround this issue? I've tried to use pgrep. But the
> difficulty of recursing to show all children of PID X by using pgrep let
> me select the pstree for this job.

Think about it.

Unless you stop the computer during your request for a specific PID
it's impossible to stop the OS from terminating that PID.

--
Dan Espen
0 new messages