multithreading - 常见的Lisp : Run function in the background

标签 multithreading shell common-lisp sbcl

在Common Lisp中在后台运行函数的最佳方法是什么?具体来说,我正在打电话(trivial-shell:shell-command "<long and complicated command>"。此操作阻塞了大约10秒钟,但是我不在乎输出,只在乎副作用-所以我希望它在后台运行,以便程序流可以继续。我尝试将整个内容包装在sb-thread:make-thread中,但这似乎没有什么不同。

如果可能的话,我将避免陷入各种复杂的线程中。我在64位Gentoo Linux上运行SBCL 1.1.18。

最佳答案

我的小调查:看来唯一的解决方案是Renzo的答案:UIOP的launch-program函数。

否则,为了运行shell命令,有

  • UIOP的其他方法,例如run-program,是同步的。
  • [下 shell https://gitlab.common-lisp.net/qitab/inferior-shell]优先于琐碎的 shell 。它使用uiop:run-program,因此只能同步运行,
  • 关于multithreading - 常见的Lisp : Run function in the background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41319173/

    相关文章:

    c - 优雅地杀死 C 的 pthread 中的阻塞线程?

    linux - 如何使用 awk 在 .csv 文件的前两行之后覆盖而不删除它们,并在预告片之前停止覆盖?

    lisp - 普通 lisp 中的 require 和 load 有什么区别?

    recursion - 从列表中递归获取最小数量

    windows - 线程如何在 Windows 上的多个处理器上执行?

    c++ - 如何确保在不同线程读取变量之前将变量存储到内存中

    multithreading - 多线程(在Java中)

    bash - Shell 脚本不清楚 ": "的用法

    linux - pwd|sed -e 是什么意思?

    stream - 读取字节忽略 SBCL 灰色流中的 eof-error-p