need help with unix / grep

Posted on
Sat Dec 12, 2015 6:51 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

need help with unix / grep

In one of my plugin I have:
Code: Select all
                p =  subprocess.Popen("ps -ef | grep programToFind | grep -v grep ",shell=True,stdout=subprocess.PIPE, stderr = subprocess.PIPE)
                ppp= p.communicate()[0].strip("\n").split("\n")
                p.stdout.close()
                p.stderr.close()
                p.wait()
               then use PPP to check if process programToFind  is running   and either restart or ...


After some days I find the mac running at 100% and there are many "grep" process consuming all the cpu. This is a basic call I have been using for some time.
I believe, I am closing the subprocess.Popen correctly.

nothing special in the system log file and nothing in the indigo log file


.. any advice from THE experts?

Karl

Posted on
Wed Dec 16, 2015 8:50 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: need help with unix / grep

That looks good to me. I don't know that the wait() call is needed since the process should be terminated by the time communicate() returns. For some reason grep isn't exiting though, but I'm not sure why...

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests