Is there any way to make a background process in Mathematica so that the external command will run but not hold up other evaluations?
startTime = AbsoluteTime[];
Run["sleep 2" (*, a magic option here perhaps? *)];
AbsoluteTime[] - startTime
(* Returns 2.016960 on my system *)
I want a version of / option for Run
that will not hold up the evaluation, so that the last line in the above code will return something close to zero.
(The above will run in *nix and OSX; there doesn't seem to be any universal/portable way to "sleep 2" in a DOS/Windows shell:
Sleeping in a batch file. Although, perhaps the easiest way to get the sleep
command is to install the MS resource kit - see this answer to the Sleeping in a batch file question or the comments below.)
At the moment, the reason I want this is so that my ALSASound
command given in No sound in Mathematica under linux will not stop the fireworks. But it would also be a good improvement to ALSASound
and a useful thing to know in general.
Edit
The two solutions posted below rely on using the shell to spawn a new/child process using start cmd
in Windows/DOS and cmd&
in *nix. Is there a platform independent and/or Mathematica based solution? (Points will be awarded for the creation of a command that checks the OS using $OperatingSystem
!)