Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-02-18 09:08 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (252 votes). Check out past polls.