我不明白,为什么我不能在后台运行某个进程(在此示例中为“ cat”),然后又使其成为前台:
$ dash
$ f() { cat </dev/stdin > /dev/stdout & sleep 1; fg ; }
$ sleep 2 | f
dash: 1: fg: job (null) not created under job control
$ set -m
$ sleep 2 | f
dash: 1: fg: job (null) not created under job control
$ f() { set -m; cat </dev/stdin > /dev/stdout & sleep 1; fg ; }
$ sleep 2 | f
dash: 5: fg: job (null) not created under job control
为什么每次我收到错误消息?
在没有管道的情况下运行函数“ f”时,有时我没有此类消息:
$ set +m
$ f
cat 0</dev/stdin 1>/dev/stdout
^C
$ set -m
$ f
cat 0</dev/stdin 1>/dev/stdout
^C