What's the best way to run a function in the background, in Common Lisp? Specifically, I'm making a call like
(trivial-shell:shell-command "<long and complicated command>"
. This operation is blocking for ~10 seconds, but I don't care for the output, just the side effect - so I want it to be run in the background, so that program flow can continue. I've tried wrapping the whole thing in sb-thread:make-thread
, but that didn't appear to make a difference.
I'd avoid getting wrapped up in all kinds of complicated threading, if at all possible. I'm running SBCL 1.1.18 on 64-bit Gentoo Linux.
Here is the example with
cl-async
andbordeaux-thread
packages on SBCL. Suppose you have a shell script./echo.sh
at the current directory. You can run the script at the background. After the invocation of the script, the following code is immediately evaluated so you getWaiting.....
on your screen. After the script is done, the notifier is triggered and displaysThreaded job done.
Make sure the
*features*
containsSB-THREAD
as @coredump says.If you want to capture the stdout of shell script, add
:output t
to the argument ofsb-ext:run-program
.