Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.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
Linux 连续写入管道而不阻塞和关闭读卡器_Linux_Bash_Pipe - Fatal编程技术网

Linux 连续写入管道而不阻塞和关闭读卡器

Linux 连续写入管道而不阻塞和关闭读卡器,linux,bash,pipe,Linux,Bash,Pipe,我今天要做的是不阻塞地从命名管道读/写, 并关闭两侧的管道,而不终止流程。 在firset wright进入管道后,我正在努力关闭流程。 我有一些代码要你帮我解决困难 mkfifo _gnupg_pipe_command gpg --homedir ./ --batch --verbose \ --pinentry-mode loopback \ --gen-key _gnupg_pipe_command & cat >

我今天要做的是不阻塞地从命名管道读/写, 并关闭两侧的管道,而不终止流程。 在firset wright进入管道后,我正在努力关闭流程。 我有一些代码要你帮我解决困难

    mkfifo _gnupg_pipe_command

    gpg --homedir ./ --batch --verbose \
        --pinentry-mode loopback \
        --gen-key _gnupg_pipe_command &

    cat > $_gnupg_pipe_command <<EOF
%echo Generating a basic OpenPGP key
Key-Type: RSA
Key-Length: 4096
Key-Usage: sign
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: $_gnupg_name
EOF

    if [ -v _gnupg_comment ]; then
        cat > _gnupg_pipe_command <<EOF
Name-Comment: _gnupg_comment
EOF
    fi

    cat > _gnupg_pipe_command <<EOF
Name-Email: _gnupg_email@_gnupg_universe
Expire-Date: 1y
Passphrase: _gnupg_passphrase_key
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
mkfifo\u gnupg\u pipe\u命令
gpg--homedir./--batch--verbose\
--松垂模式环回\
--gen key_gnupg_pipe_命令&

cat>$\u gnupg\u pipe\u command将所有命令放在一个列表或子shell中,并将整个内容重定向到管道

{ 
command1
command2
command3
} > _gnupg_pipe_command
管道将在开始时仅打开一次,并在所有命令完成后关闭

如果是一行,则需要适当的空格和
,因为
{
}
不是自定界语法,它们是关键字

{ cmd1; cmd2; cmd3; } > _gnupg_pipe_command

显然,问题中的脚本不能是一行程序,因为这里有文档。

可能会有帮助。为什么管道文件名前面有
$
?请注意,如果有人想这样做,空格和最后分号很重要
{cmd1;cmd2;cmd3;}