RE: Interesting race condition...

Robert White
2004-08-04T20:04:25Z

Using procps version 2.0.7 the inclusion of "e" in the arguments is documented to
return environment of the process.

So the below issues with "ps eaxf" are only surprising in that you claim the pipe is
necessary to see the environment. Ps has "always" done slightly different things
when used at the head of a pipe. In particular it will trim it's right side when not
in a pipe to keep the display readable, while in a pipe the lines will be "as long as
necessary."

The question of why the original poster was getting the environment when only using
"ps ax" is interesting. I'd look for PS_PERSONALITY (etc) in the ps-executing
environment. [consult your manual.]

And so on...

Rob.

-----Original Message-----
From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-owner@vger.kernel.org]
On Behalf Of Bill Davidsen
Sent: Tuesday, July 27, 2004 1:40 PM
To: linux-kernel@vger.kernel.org
Subject: Re: Interesting race condition...

Rob Landley wrote:
> On Friday 23 July 2004 05:01, P. Benie wrote:
>
>>On Fri, 23 Jul 2004, Rob Landley wrote:
>>
>>>I just saw a funky thing. Here's the cut and past from the xterm...
>>>
>>>[root@(none) root]# ps ax | grep hack
>>> 9964 pts/1 R 0:00 grep hack HOSTNAME= SHELL=/bin/bash TERM=xterm
>>>HISTSIZE=1000 USER=root
>>>LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=
>>>40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.
>>>com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz
>>>= [root@(none) root]# ps ax | grep hack
>>> 9966 pts/1 S 0:00 grep hack
>>>
>>>Seems like some kind of race condition, dunno if it's in Fedore Core 1's
>>>ps or the 2.6.7 kernel or what...
>>
>>The race is in the shell's pipeline - the processes don't start at exactly
>>the same time, and sometimes ps has completed before the shell has
>>started grep. This is the expected behaviour.
>
>
> It's expected behavior for PS to show a process's environment variables as
> part of its command line?

When piped. For instance
ps eaxf
does not, while
ps eaxf | cat
does, at least on my systems. I tried on RHEL AS3.0 thru a four year old
version of Slackware, all did the same thing.

--
-bill davidsen (davidsen@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/