"Strong Scripting Skills" - a definition? - sunday
Robert Hajime Lanning
lanning at lanning.cc
Sun Jan 25 17:07:41 PST 2004
<quote who="Alvin Oga">
> sometimes grep -v grep is needed, sometimes not... i donno why some
> greps does it differently
Actualy, this is caused by a race condition.
ps -axuw | grep foo | grep -v grep | awk '{print $2}' | xargs kill
Each seperate command gets fork()ed and exec()ed with the pipes setup between
them.
Now, the question is, will the "ps -axuw" initialize and read the process table
before or after "grep foo" is exec()ed. If before, then "ps -axuw" will not
have "grep foo" in its listing. If after, then "ps -axuw" will have "grep foo"
in its listing.
--
END OF LINE
-MCP
More information about the Baylisa
mailing list