Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Strange behaviour: $! is set after successful socketpair() call

by kennethk (Abbot)
on Apr 12, 2014 at 20:53 UTC ( #1082123=note: print w/replies, xml ) Need Help??

in reply to Strange behaviour: $! is set after successful socketpair() call

From $! in perlvar:
Many system or library calls set errno if they fail, to indicate the cause of failure. They usually do not set errno to zero if they succeed. This means errno , hence $! , is meaningful only immediately after a failure
You can't use $! as an indicator of whether a call failed. I am not particularly familiar with what you are attempting, but assuming using $! to check success on modifying $) is appropriate, I would probably implement that bit as:
EGID_BLOCK: { my $cache = $!; $) = $run_gid; die "Setting egid: $!" if $! and $! ne $cache; }
This brings it more in line with the principle of least surprise, since the funky checks are all localized to the block. This could also function using localization or explicit undef.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2016-10-25 18:05 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (326 votes). Check out past polls.