Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Co-processes in Korn shell

Status
Not open for further replies.

bbelous

Technical User
Jul 10, 2001
3
US
Does anyone know how to keep a coprocess opened via "|&" alive after the "parent" session under which the coproces was opened ends?

I am trying to have a co-process running to which I could submit commands / jobs and from which I could get the results of those commands / jobs.

thanks
Boris Belous
bbelous@hotmail.com
 
You could try using nohup.

This allows you to run a command immune to hangups, though whether this applies in the parent/child scenario I don't know. Give it a go and let us know. Cheers.
 
Thanks for the tip. However, nohup does not seem to be working with co-processes. In other words:

%>ksh
%>ksh
%>nohup [my_program] |&
[1] some_process_#
%>exit
%>kill -9 some_process_#
kill: some_process_#: no such process

Also sending a co-processor to a descriptor for later reference in order to either send commands to it or receive command output from it presents a problem as the descriptors also die upon exit from the shell that originated the co-process.

%>ksh
%>ksh
%>nohup [my_program] |&
[1] some_process_#
%>exec 5>&p #send co-process to descr. 5 for input
%>exec 6<&p #send co-process to descr. 6 for output
%>print -u5 &quot;some_program_command&quot;
later I can read output via read -ru6...
%>exit
%>print -u5 &quot;some_program_command&quot;
ksh: print: bad file unit number

The bottom line, I am looking for a mechanism that would be conceptually similar to a named pipe, only instead of being able to send and receive data streams I want to be able to send and receive command input and command output.

Thanks
Boris Belous
bbelous@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top