Starting a program on Mac OS

Archives Forums/MacOS X Discussion/Starting a program on Mac OS

Blueapples(Posted 2008) [#1]
I'm having a hard time getting applications to start using either OpenURL or CreateProcess. I am passing in the actual binary path but not getting any success:

OpenURL("~/dllp.app/Contents/MacOS/xulrunner")
CreateProcess("~/dllp.app/Contents/MacOS/xulrunner")

Neither of these work, although system_() seems to work. I would really like to have CreateProcess working as I have a library of functions that rely on TProcess objects to do stuff like wait for a process to close, etc. Does that class work at all on Mac OS?


Winni(Posted 2008) [#2]
And dllp.app is in the user's home directory (because that's what the ~ stands for)?


Blueapples(Posted 2008) [#3]
Let's just say it is, in my real app I have the full directory taken from AppDir. I guess my examples should just have that spelled out, this is closer to what I'm actually doing:


start.bmx
Local P:TProcess = CreateProcess(AppDir + "/dllp.app/Contents/MacOS/xulrunner")


dllp.app is a xulrunner based application in the same directory as "start.app" (when this is compiled). I've also tested to make sure that AppDir only returns the application directory - not the Contents/MacOS dir (which you can get by calling StripDir() on AppFile).

I did see this comment in FreeProcess.bmx:

1.01 Release
Inserts /Contents/MacOS/ into process path for Apple app packages


I can't find any evidence of this in the BMX or C code. If it does do that, I wonder how and if it is in a way that interferes with how I'm using it (by providing that path myself).


SebHoll(Posted 2008) [#4]
See line 144 of freeprocess.bmx. It is blindly attempting to find the executable assuming that it will have the same name as the Application Folder (which won't always be the case). Perhaps, instead, it should read the executable name from info.plist, only resorting to using the previous fail-safe method if no definition is found. However, as you can see from the code, it is only doing this if the path supplied is a directory, which I assume is not the case in your example.

?MacOS
		If FileType(name)=2
			Local a$=StripExt(StripDir(name))
			name:+"/Contents/MacOS/"+a$
		EndIf
?



Blueapples(Posted 2008) [#5]
Don't know how I missed that, but good to rule it out as the cause of my problem. Well this is weird, this works fine:

Local P:TProcess = CreateProcess("/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal")

DebugStop


P seems to be completely populated. So then it would seem that either I have a typo which no one can help me with, or xulrunner doesn't like something about the way it's getting started. Thing is, I don't see what could be wrong with the execv() it uses to start the application. Maybe I should try calling that directly and see what happens...