Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've had enough trying to figure out this bug and am ready to throw in the towel. As a last resort, I thought I'd ask here.

At this url (bundle.tar, 39K) is a cut-down version of the problem. Too much code to post, I'll give an walkthrough on creating the bug momentarily.

The problem is this: I've got multiple incoming sockets (IO::Socket::INET) that I'm managing I/O using select (IO::Select), when I have the listening program call Win32::Process::Create all of the *already established* sockets stop working. They don't report an error, it's just that select() on them stops working. It doesn't seem to matter what the program Win32::Process:Create calls actually does (the .exe included is a "Hello, world") it always causes this.

From what I've read, the third flag to W:P:C is supposed to control file descriptor inheritance by children, but I can't get it to work one way or the other and it may not even be the problem. If this were Unix, it'd feel like a child-closing-parent's-descriptors problem but I'm not entirely sure how Win32 is handling all of this.

So to re-create the bug, do this:

  1. Unpack the tar bundle noted above.
  2. Start the program "testcase.pl". It's going to create "logfile" and update it as it goes along. No other output from "testcase.pl" is really important...
  3. Start a "tail -f logfile" or the equivalent for your OS and toolset. This is what to watch.
  4. Start a copy of "logstuff.pl". This will continually send stuff over an open socket to testcase.pl, which you can watch in the logfile.
  5. Once that's going, wait a few seconds and start "client.pl". This will send a 1-time request to testcase.pl to call an external program. (It'll probably report an "Err: No output", don't sweat it.)
And what you'll see in the logfile is a continuous stream of input from the logstuff.pl program, until the client.pl program runs and finishes. At that point testcase.pl stops receiving input, even though it's still checking the socket with select.

If you start multiple logstuff.pl instances, this doesn't happen. They can connect, disconnect, etc... without problem.

And once testcase.pl has (buggily) dropped all of the other incoming sockets, re-establishing new connections work fine. The prior ones are still ignored however.

If anyone knows the reason for this nonsense between select()/W:P:C I'd love to know the answer. I've searched the newsgroups and documentation and I'm resonably sure there's not an obvious answer. And I don't *think* I've got a bug in my code because I've marked everywhere I'm opening/closing/reading/writing sockets and I'm sure I haven't accidentally killed something.

Thank you for your time!

PS: Keep your style nits to yourself, remember this is a stripped down/test case version of something much larger.

In reply to Win32::Process::Create and IO::Select bad interaction by clintp

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2021-11-28 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?