Shell and Background Jobs
form at nonsanity.com
Tue Aug 23 16:32:20 EDT 2011
Now that the earth has stopped shaking here, I can re-write this email. I
lost the first rendition by switching to the USGS web site for details on
the 5.9 earthquake we had nearby (geographically speaking). Anyway...
I've been trying to do some shell() background jobs on the Mac, ones that
will take a long time to execute. Sometimes adding the & to the end of the
string I pass to shell() makes shell return immediately, and I can see the
task started in Process Monitor. Other times shell keeps control until the
task is done (or I kill it in frustration).
I made a new stack with a button and a field and put this script in the
put "start" into fld 1
get shell( "sleep 5 &" )
put "end" into fld 1
Now that SHOULD background the sleep so that shell returns immediately and
replaces the "start" with "end" in fld 1 so that you never really even see
the "start". But I get 5 seconds of "start" before "end" appears.
In Terminal, the same "sleep 5 &" will return immediately, while leaving off
the "&" will make it delay 5 seconds before getting a new prompt.
At the same time, I have a big, complex HandBrake command that DOES
background correctly. I can't figure out why that one works consistently. :(
Has anyone else researched this and found some pertinent facts they can
(WHY OH WWHHYY doesn't the "start process" commands work on Macs????)
~ Chris Innanen
More information about the Use-livecode