-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to subprocess.call #78
base: master
Are you sure you want to change the base?
Conversation
Popen is depreciated wait() which is needed for bugfix wbond#45 Switched to subprocess.call
Migrated to subprocess.call
@@ -85,7 +85,8 @@ def get(): | |||
else: | |||
ps = 'ps -eo comm | grep -E "gnome-session|ksmserver|' + \ | |||
'xfce4-session" | grep -v grep' | |||
wm = [x.replace("\n", '') for x in os.popen(ps)] | |||
wm = [x.replace("\n", '') for x in subprocess.call(ps)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.popen
returns a readable file object with the matching running session commands (e.g. gnome-session
).
subprocess.call
returns the exit code. Instead of this, we will need to use subprocess.PIPE
or subprocess.check_output
with a split
https://docs.python.org/3.4/library/os.html#os.popen
https://docs.python.org/3.3/library/subprocess.html#subprocess.call
While there was a deprecation notice in Python 2.7, it seems to have disappeared in Python 3.3/3.4: https://docs.python.org/2.7/library/os.html#os.popen https://docs.python.org/3.3/library/os.html#os.popen https://docs.python.org/3.4/library/os.html#os.popen Aside from that, can you elaborate more on the |
So a defunct/zombie process on Unix is caused by a parent process that forks a child, but never checks the return code. To make this go away, I believe we just need to call https://en.wikipedia.org/?title=Zombie_process |
As documented in Python 2.7, we could also use https://docs.python.org/2.7/library/os.html#os.popen handle = os.popen(ps)
wm = [x.replace("\n", '') for x in handle]
handle.close() |
We jus need to make sure we look at 2.6 since that is what ST2 uses. |
the current implementation of popen does not allow for the wait() so we do not have any errors. With subprocess.call it includes the wait anyway. Also popen is depreciated to subprocess.call