
{"id":7390,"date":"2012-06-11T15:17:59","date_gmt":"2012-06-11T15:17:59","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=7390"},"modified":"2012-06-11T15:17:59","modified_gmt":"2012-06-11T15:17:59","slug":"coproc-coprocesses-in-gnu-bash","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2012\/06\/11\/coproc-coprocesses-in-gnu-bash\/","title":{"rendered":"coproc  is a shell keyword  related to  coprocesses  in GNU Bash"},"content":{"rendered":"<p><u>ABOUT coproc<\/u><\/p>\n<pre>\nBash 4.0 introduced coprocesses, a feature certainly familiar to ksh users. The coproc keyword starts a command as a background job, setting up pipes connected to both its stdin and stdout so that you can interact with it bidirectionally. Optionally, the co-process can have a name NAME. If NAME is given, the command that follows must be a compound command. If no NAME is given, then the command can be either simple or compound.\n\nThe process ID of the shell spawned to execute the coprocess is available through the value of the variable named by NAME followed by a _PID suffix. For example, the variable name used to store the PID of a coproc started with no NAME given would be COPROC_PID (because COPROC is the default NAME). The wait builtin command may be used to wait for the coprocess to terminate. Additionally, coprocesses may be manipulated through their jobspec\n<\/pre>\n<p>[bash]<br \/>\n$coproc ls<br \/>\n[1] 4620<br \/>\n$coproc ls<br \/>\nbash: warning: execute_coproc: coproc [4620:COPROC] still exists<br \/>\n[2] 4621<br \/>\n[1]   Done                    coproc COPROC ls<br \/>\n$coproc top<br \/>\nbash: warning: execute_coproc: coproc [4621:COPROC] still exists<br \/>\n[3] 4622<br \/>\n[2]   Done                    coproc COPROC ls<br \/>\n$top: failed tty get<\/p>\n<p>[3]+  Exit 1                  coproc COPROC top<br \/>\n$coproc date<br \/>\n[1] 4624<br \/>\n$coproc arch<br \/>\nbash: warning: execute_coproc: coproc [4624:COPROC] still exists<br \/>\n[2] 4625<br \/>\n[1]   Done                    coproc COPROC date<br \/>\n$coproc arch<br \/>\nbash: warning: execute_coproc: coproc [4625:COPROC] still exists<br \/>\n[3] 4628<br \/>\n[2]   Done                    coproc COPROC arch<br \/>\n$fg 1<br \/>\nbash: fg: 1: no such job<br \/>\n[3]+  Done                    coproc COPROC arch<br \/>\n$<br \/>\n[\/bash]<br \/>\nLINKS<br \/>\n<a href=\"https:\/\/wiki-dev.bash-hackers.org\/syntax\/keywords\/coproc\">https:\/\/wiki-dev.bash-hackers.org\/syntax\/keywords\/coproc<\/a><br \/>\n<a href=\"http:\/\/blog.amit-agarwal.co.in\/2010\/05\/10\/coproc-feature-bash\/\">http:\/\/blog.amit-agarwal.co.in\/2010\/05\/10\/coproc-feature-bash\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ABOUT coproc Bash 4.0 introduced coprocesses, a feature certainly familiar to ksh users. The coproc keyword starts a command as a background job, setting up pipes connected to both its stdin and stdout so that you can interact with it bidirectionally. Optionally, the co-process can have a name NAME. If NAME is given, the command &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2012\/06\/11\/coproc-coprocesses-in-gnu-bash\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;coproc  is a shell keyword  related to  coprocesses  in GNU Bash&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,83],"tags":[457,587,995],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7390"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=7390"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7390\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=7390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=7390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=7390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}