On 23 Mar, 04:24, "Luke" <lba... / gmail.com> wrote: > Thanks for the heads up on the AppleScript gem, I checked that out > also and had some problems because I'm trying to deploy a cross- > platform gem and creating a dependency on those tools looked like they > may cause problems for win users. Gem auto-unpacked the exts when it > was resolving dependencies. OS X's GUI and CLI environments have distinctly different ways of doing business and don't integrate too well out of the box, so conventional Unixisms like fork, argv and kill tend not to go down so well with GUI apps (as you've noticed). The standard API for launching apps and opening documents is LaunchServices and IPC is normally done via Apple events, but if Mac-specific C extensions are out then I think you're about down to kludging it. > The closest thing I've come up with so far is initiating the process > with "open" and then using "ps -a" and regex to poll for the status of > the launched process. This is definitely pretty far from ideal, so I > would be surprised if that's what it's going to take. See also 'osascript', which can be used to execute AppleScripts on the fly. One other thing to remember: as a rule, OS X shouldn't have more than one instance of a given application running at a time (it's technically possible, but is largely frowned upon). Aside from being another reason not to mess about with fork; this also means it's normally pretty safe to identify apps by bundle id/bundle path (or even file name), so obtaining and working with a process id generally isn't essential. HTH has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org http://appscript.sourceforge.net/objc-appscript.html