Does anyone have experience with NSTask?
I’ve made a class that I use for launching async NSTask shells. (I’m using MacOSLlib because I can’t figure out how to make the declares myself.)
It works ok but after a while, I get posix_spawn error 35 (couldn’t spawn) and the whole thing crashes. The crash occurs at the NSTask.lanch command in MacOSLlib.
The problem is, sometimes it runs for an hour, sometimes it crashes within seconds. Sometimes when it’s busy (100’s per second), sometimes when it’s not busy at all.
Not sure but I think it has to do with me polling ‘.isRunning’ using a timer (within the instance) and then reading the output using NSData = Me.StdoutPipe.ReadHandle.ReadAll. Maybe some timing conflict?
Instead of using a timer, is there a trick where I somehow can add a handler to a NSTask event? The reference doesn’t give me much to attach it to. Also, it mentions that .isRunning is no longer supported. (not sure why because it normally works on my Yosemite 10.10.4)
[quote=205578:@Marco Hof]Ok. lol
Well, a 08/15 is not allowed if you want your App sandboxed in the MAS.
I’m not sure why Xojo doesn’t use NSTask internally for it’s shells.[/quote]
Sorry to contradict, but almost all my 16 apps in the MAS use the plain Xojo shell, and two of them are UI skins for command lines. The legend of shell being forbidden in the MAS is completely bogus.
Shell is fone for system provided console applications, but if you want to invoke a console application included within your application bundle, it must be Sandboxed; once it’s Sandboxed it can only be launched from NSTask and not the regular Xojo shell.
This is of course you want to ship your application on the Mac App Store.
[quote=205723:@Sam Rowlands]Shell is fone for system provided console applications, but if you want to invoke a console application included within your application bundle, it must be Sandboxed; once it’s Sandboxed it can only be launched from NSTask and not the regular Xojo shell.
This is of course you want to ship your application on the Mac App Store.[/quote]
Indeed, launching a Xojo console app from the standard shell withing a sandboxed application does not work.