develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #98934] set{u,g}id doesn't clear $! on success

Thread Previous
September 13, 2011 04:02
Re: [perl #98934] set{u,g}id doesn't clear $! on success
Message ID:
Chris Adams wrote:
>Setting a user/group ID by assigning to the perl special variables does
>not clear $!,

Yes, generally $! is not cleared by successful operations.  It is an exact
mirror for the C level errno.  You need an independent way to see whether
the operation succeeded, such as getting -1 from a syscall, and only
check $! on failure.  Unfortunately, assignment to magic variables doesn't
provide a way to report failure.  You've run into the edge of the model
here: this is where the magic variables stop behaving like variables.

I suggest that you use setgid() from the POSIX module.  Unfortunately it
seems not to have setegid() and friends; patches welcome.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About