|
From: BobbyH on 21 Nov 2006 15:40 I can create a co-process and read from the process with commands like: ============================ $ cat /etc/passwd |& $ read -p1 line $ echo $line root:x:0:0:Super User:/:/bin/sh $ read -p1 line $ echo $line daemon:x:1:1::/: $ ============================= My questions are: 1) How can I determine what co-process numbers are open? AND 2) How can I close a co-process when I have finished using it? bhiggins(a)airmail.net
From: rajesh.tamil.india@gmail.com on 22 Nov 2006 03:43 1. There is only one co-process at a time, if you want to use more than one, then the input and output should be redirected using >&p <&p. 2. Redirect the input of the co-process by exec 5<&p; exec 5<&- BobbyH wrote: > I can create a co-process and read from the process with commands like: > ============================ > $ cat /etc/passwd |& > $ read -p1 line > $ echo $line > root:x:0:0:Super User:/:/bin/sh > $ read -p1 line > $ echo $line > daemon:x:1:1::/: > $ > ============================= > My questions are: > 1) How can I determine what co-process numbers are open? > > > AND > > 2) How can I close a co-process when I have finished using it? > > bhiggins(a)airmail.net
From: Michael Paoli on 26 Nov 2006 18:18 BobbyH wrote: > I can create a co-process and read from the process with commands like: > ============================ > $ cat /etc/passwd |& > 1) How can I determine what co-process numbers are open? $! Either save it immediately after starting your co-process, or if you haven't started any other co-processes or background/asynchronous processes, you can still refer to $!. You can also use jobs or jobs -l to get jobs, and optionally PIDs, but which are co-processes vs. other asynchronous jobs may not be easy to determine. > 2) How can I close a co-process when I have finished using it? "close a co-process"? What are you asking, exactly? You can redirect and close its stdin and/or stdout, and/or you can terminate (kill(1)) the process (by PID, or by job with ksh's kill).
|
Pages: 1 Prev: Rsync --exclude option Next: printing stings in bc -- basic calculator |