Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > pipe possible to an already running process?

Reply
Thread Tools

pipe possible to an already running process?

 
 
.rhavin grobert
Guest
Posts: n/a
 
      01-08-2006
hi there

I have a little inter-process-communication problem...
_______________________

Lets say you have two Skripts [#A and #B]. #A is already running and
has left it's PID ($$) in a file, waiting inside a loop for one or more
instances of #B.
#B is invoced by the web-user, reads the file and now has to establish
a connection to #A - just knowing it's PID and sending a string to #A
containing something like:
'Hi, my ID is $$'
#A will accept the connection, receive the string and connect to #B in
return.
_______________________

The problem is that I dont know how to do that practically;-|

I tryed kill / @SIG, but that doesnt give me the possibility to send
strings (unless i subclass 127 SIGs and transform my string into 7bit;
this will be the last possibility i'd choose

Another try of mine was a pipe() in #A and #B, but i dont fork a single
prog, i have two different ones already running and simply didn't find
a way to exchange the pipe-handles between the programs.

I've read perlipc and spend a day googlin' but still dont have a clue,
so any help or some URL to a source doing something similar would be
fantastic.

-.rhavin

 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      01-09-2006
..rhavin grobert <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> hi there
>
> I have a little inter-process-communication problem...


Yes, we've heard you the first couple of times. Don't post the
same question repeatedly.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
 
Reply With Quote
 
 
 
 
Bodo Eing
Guest
Posts: n/a
 
      01-09-2006
..rhavin grobert wrote:

> hi there
>
> I have a little inter-process-communication problem...
> _______________________
>
> Lets say you have two Skripts [#A and #B]. #A is already running and
> has left it's PID ($$) in a file, waiting inside a loop for one or more
> instances of #B.
> #B is invoced by the web-user, reads the file and now has to establish
> a connection to #A - just knowing it's PID and sending a string to #A
> containing something like:
> 'Hi, my ID is $$'
> #A will accept the connection, receive the string and connect to #B in
> return.
> _______________________
>
> The problem is that I dont know how to do that practically;-|
>
> I tryed kill / @SIG, but that doesnt give me the possibility to send
> strings (unless i subclass 127 SIGs and transform my string into 7bit;
> this will be the last possibility i'd choose
>
> Another try of mine was a pipe() in #A and #B, but i dont fork a single
> prog, i have two different ones already running and simply didn't find
> a way to exchange the pipe-handles between the programs.
>
> I've read perlipc and spend a day googlin' but still dont have a clue,
> so any help or some URL to a source doing something similar would be
> fantastic.
>
> -.rhavin
>


What you want is synchronous client/server communication. perlipc
provides some hints in the "Sockets: Client/Server Communication" section.

Several solutions:

1. Let #A and #B communicate via temporary files. This may require the
least modifications to your existing code, but needs some thoughts on
file locking and precautions in case your communication gets out of
sync. This solution ist not very effective and not very robust, but it
has worked for me stably with "low volume" communication (approx. 10
request/response cycles per second).

2. Reconsider your design and try to write all of it as an
Apache/mod_perl app, obviating the need for two separate scripts (best
but hardest alternative, requires most skills and requires control over
your web server).

3. Use http: Wrap #A into HTTP:aemon or HTTP::Server::Simple and let
#B communicate with #A via LWP::Simple or LWP::UserAgent. If you got so
far, you may find that #B is superfluous, since the user's browser can
now directly communicate with #A. You may then be tempted to shift all
of #B's functionality (e.g., request parsing, HTML generation) to #A.
When you have done this, you will find that you have solution 2 with
(some of) the Apache part written by you in Perl. It's up to you to know
if this is a good idea. So this solution is only of some value if you
restrict #A's functionality to serving the data, and #B running as a CGI
script, doing all the rest. I guess that this is the basic design you
have chosen already anyways.

4. Do not mess around with forks and pipes on the low level.

Regards

Bodo
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read pipe information on a running (popen) process Jules Stevenson Python 0 01-06-2009 09:48 PM
Terminal input and pipe - possible to have both? kotzkroete@gmail.com C Programming 6 11-04-2007 09:10 PM
pipe to an already running process? .rhavin grobert Perl Misc 0 01-08-2006 11:47 PM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM



Advertisments