Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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 God said, "Let Newton be!"...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-03-24 13:31 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.