鱼壳如何在后台启动进程的PID

亚历山大·桑托斯

在FiSH(友好交互式外壳)中,我可以在后台(something &开始一个过程但是,如果我尝试检索进程(PID=$!的进程ID,则会从fish中得到一个错误:

fish: Unknown command “PID=$!”. Did you mean “set PID $!”? For information on assigning values to variables, see the
help section on the set command by typing “help set”.
PID=$!: command not found

如何获取后台进程的PID?

格伦·杰克曼

使用流程扩展,您可以编写

set PID %1          # if you know it's the first background job
set PID %something  # if you know it's the only "something" running

请注意,此功能在fish版本3中删除

否则,我们可以使用jobs命令

set PID (jobs -l | awk '{print $2}')    # just get the pid
jobs -l | read jobid pid cpu state cmd  # get all the things

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章