做了一些在线搜索,找到了使用命名管道的简单"教程".但是,当我对后台工作做任何事情时,我似乎丢失了大量数据.
[[编辑:发现一个更简单的解决方案,请参阅回复帖子.所以我提出的问题现在是学术性的 - 如果有人想要一个工作服务器]]
使用Ubuntu 10.04和Linux 2.6.32-25-generic#45-Ubuntu SMP Sat Oct 16 19:52:42 UTC 2010 x86_64 GNU/Linux
GNU bash,版本4.1.5(1)-release(x86_64-pc-linux-gnu).
我的bash功能是:
function jqs
{
pipe=/tmp/__job_control_manager__
trap "rm -f $pipe; exit" EXIT SIGKILL
if [[ ! -p "$pipe" ]]; then
mkfifo "$pipe"
fi
while true
do
if read txt <"$pipe"
then
echo "$(date +'%Y'): new text is [[$txt]]"
if [[ "$txt" == 'quit' ]]
then
break
fi
fi
done
}
Run Code Online (Sandbox Code Playgroud)
我在后台运行:
> jqs&
[1] 5336
Run Code Online (Sandbox Code Playgroud)
现在我喂它:
for i in 1 2 3 4 …Run Code Online (Sandbox Code Playgroud)