Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Socket descriptor passed across fork -- hanging

by dd-b (Monk)
on Oct 13, 2011 at 15:31 UTC ( [id://931279]=note: print w/replies, xml ) Need Help??


in reply to Socket descriptor passed across fork -- hanging

So what does it mean when the following code:

$! = 0; $res = $sock->read($data, 255); # $res: #chars, or 0 for EOF, or undef for error $err = $!; $iologger->debug("bufrd res " . safe($res) . ": " . safe($data) . " err $err");

Logs this:

2011-10-13 09:21:39,782 DEBUG kcmdproxy.child.io(30674):366 bufrd res +<<127>>: <<simkserver<sp>30665<sp>port<sp>2001<sp>client<sp>127.0.0.1 +<sp>command<sp>special<lf>1,8,7,2,13,1,12<lf>13,5,11,10,8,0,13<lf>5,2 +,11,4,5,10,5<lf>3,5,7,10,12,2,12<lf>>> err Resource temporarily unava +ilable

The socket call returned 127, which should be a number of characters (and looks about right). And it also set $! (which I had carefully set to 0 before the call). There isn't threading going on, and the signal handling is at the level of setting one variable in the handler, so nothing else should be interrupting to set $!. I suppose I could localize it, just as a test, to see if this still happens, but I don't see how something else can be getting in to set it. Does the $! value mean anything in this case, or is it just garbage?

Replies are listed 'Best First'.
Re^2: Socket descriptor passed across fork -- hanging
by SuicideJunkie (Vicar) on Oct 13, 2011 at 15:38 UTC

    $! only has meaning if the operation failed. After a success its value could be anything.

    perldoc says: If used numerically, yields the current value of the C errno variable, or in other words, if a system or library call fails, it sets this variable. This means that the value of $! is meaningful only immediately after a failure:

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://931279]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-28 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found