Hi all,
Tough question, searched the web for hours and everything. The python function Popen from the subprocess module can be used to launch processes, easy enough. I want to use this to launch URLs in Safari and obtain the PID of the Safari process. Normal circumstances would allow this but since you have to use the open() call to launch the URL Popen.pid actually returns the pid of the open() process (or some sub-process launched by it, either way it isn't Safari's)
example:
>>> p = Popen(["open","-n","http://www.apple.com"])
>>> p.pid
63272
now (from the MacOS directory of the Safari bundle) if I did:
p = Popen(["./Safari"]) and printed p.pid it gives me the pid b/c I'm launching the process directly.
Anyone ever messed around with this? Is there another way of launching Safari right into a URL without using the open() call? Lastly, is the open() call open source maybe? Could it be modified to return a child pid or something?
Thanks!
John
Tough question, searched the web for hours and everything. The python function Popen from the subprocess module can be used to launch processes, easy enough. I want to use this to launch URLs in Safari and obtain the PID of the Safari process. Normal circumstances would allow this but since you have to use the open() call to launch the URL Popen.pid actually returns the pid of the open() process (or some sub-process launched by it, either way it isn't Safari's)
example:
>>> p = Popen(["open","-n","http://www.apple.com"])
>>> p.pid
63272
now (from the MacOS directory of the Safari bundle) if I did:
p = Popen(["./Safari"]) and printed p.pid it gives me the pid b/c I'm launching the process directly.
Anyone ever messed around with this? Is there another way of launching Safari right into a URL without using the open() call? Lastly, is the open() call open source maybe? Could it be modified to return a child pid or something?
Thanks!
John