So I've started fiddling with Net::Server, and so far so good. I no longer need to write all of this accept/fork/wait for child type routines. I also gave the author some comments, and I think a couple of them actually went into the newer version.

Now I have a problem , though. The way I'd like to use this is so that my server which extends Net::Server receives requests, and then forks off a child that performs certain tasks.

One of the underlying packages ( an in-house thing ) is a sort of a rsh-type thing which works _very_ well. you can run arbitrary commands anywhere, and you get to control logs, input, output. Think of it as a Telnet.pm on steroids. ( the only drawback being that it was written for perl4 / early perl5 )

So when I fork from the Net::Server subclass, I want to use this package to talk to other machines. However, it seems to be confused about where to read from or write to, presumably because Net::Server does some funky things with these handles... As far as I could tell, it switches STDOUT and STDERR with the equivalent of the incoming sockets, and STDERR points to STDOUT. I thought that dup'ing these handles before hand and restoring them after forking would fix the problem, but apparently not.

The underlying package seems to be forking as well, and creates a pipe to the ( possibly ) remote process' std(out|err|in).. it's somehow getting very confused there, I think

At this point I don't even know if I'm going about the correct way... Can anybody tell me how to set all of these std(out|err|in) related settings to the 'default' state, as in when the script was invoked without Net::Server?


In reply to Restoring std(outerrin) with Net::Server by lestrrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.