gpt4 book ai didi

lisp - cmucl : run-program output process exited only

转载 作者:太空宇宙 更新时间:2023-11-03 18:57:35 25 4
gpt4 key购买 nike

我正在使用 debian stretch 并从稳定存储库安装 CMUCL。尝试以下操作时

(run-program "sh" '("ls") :output T)

我明白了

#<process 2845 :EXITED>

没有预期的输出。有什么帮助吗?

最佳答案

阅读ls(1)dash(1) & bash(1) .注意 POSIX /bin/sh通常是其中之一的符号链接(symbolic link)(通常是 dash,有时是 bash)。注意 PATH variable 的作用(例如在 shellsexecvp(3) 中)。和 system(3)正在使用 /bin/sh-c,而你的 sh(假设它是一个 POSIX shell)需要 -c 将字符串解释为命令。

你可以试试

  (run-program "/bin/ls" nil :output t)

  (run-program "/bin/sh" '("-c" "ls") :output t)

您的 working directory 中可能没有 ls (但在您的 PATH 中的其他地方;在 POSIX 上它应该是 /bin/ls)并且 /bin/ls 不是 shell script , 但有些 ELF可执行文件(在 Linux 上;在大多数 Unix 上它是一些 executable 而不是脚本)。所以 /bin/sh ls(或 sh ls)无法如您所愿地工作。

运行 ls 不需要启动 shell!并且您可能不需要为此目的(列出文件)派生 ls 进程,因为您可以调用 opendir(3) readdir(3) stat(2) closedir(3)作为FFI (或找到 some 包这样做)。

附言。我用过SBCL测试这些。

关于lisp - cmucl : run-program output process exited only,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47667551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com