Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Operating system 在命令结束之前,如何从Elixir System.cmd/2分离进程?_Operating System_Elixir - Fatal编程技术网

Operating system 在命令结束之前,如何从Elixir System.cmd/2分离进程?

Operating system 在命令结束之前,如何从Elixir System.cmd/2分离进程?,operating-system,elixir,Operating System,Elixir,我正在尝试运行此(script.exs): Spotify会打开,但“完成”不会出现在屏幕上。我还尝试: System.cmd("zsh", ["-c" "nohup com.spotify.Client &"]) IO.puts("done.") 我的脚本仅在关闭spotify窗口时停止。是否可以在不等待命令结束的情况下运行命令?人们不应该盲目地希望系统任务能够正常工作而产生系统任务。如果系统任务崩溃,应该在调用OTP过程中采取一些操作,否则迟早会在生产中崩溃,没有人知道发生了什么以

我正在尝试运行此(script.exs):

Spotify会打开,但“完成”不会出现在屏幕上。我还尝试:

System.cmd("zsh", ["-c" "nohup com.spotify.Client &"])
IO.puts("done.")

我的脚本仅在关闭spotify窗口时停止。是否可以在不等待命令结束的情况下运行命令?

人们不应该盲目地希望系统任务能够正常工作而产生系统任务。如果系统任务崩溃,应该在调用OTP过程中采取一些操作,否则迟早会在生产中崩溃,没有人知道发生了什么以及为什么

有很多可能的场景,我会选择(假设调用进程陷阱存在),或者在监督树中的某个地方使用显式的

如果不管上面解释了什么,您都不关心健壮性,请使用下面的
Kernel.spawn/1

pid=spawn(System,:cmd,~w | zsh-c com.spotify.Client |)
#Process.monitor(pid)#同时给它一个处理错误的机会
IO.puts(“完成”)

一个人不应该盲目地希望系统任务能够正常工作而产生系统任务。如果系统任务崩溃,应该在调用OTP过程中采取一些操作,否则迟早会在生产中崩溃,没有人知道发生了什么以及为什么

有很多可能的场景,我会选择(假设调用进程陷阱存在),或者在监督树中的某个地方使用显式的

如果不管上面解释了什么,您都不关心健壮性,请使用下面的
Kernel.spawn/1

pid=spawn(System,:cmd,~w | zsh-c com.spotify.Client |)
#Process.monitor(pid)#同时给它一个处理错误的机会
IO.puts(“完成”)

您不关心
zsh-c..的结果。
?您不关心
zsh-c..的结果。
System.cmd("zsh", ["-c" "nohup com.spotify.Client &"])
IO.puts("done.")