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

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

Thread Previous | Thread Next
From:
Jan Dubois
Date:
September 13, 2011 12:55
Subject:
RE: [perl #98934] set{u,g}id doesn't clear $! on success
Message ID:
003001cc724f$033c2d40$09b487c0$@activestate.com
On Tue, 13 Sep 2011, Leon Timmermans wrote:
> First of all, that is exactly what you should expect. Succeeding
> system calls do not set errno, only failing ones do. If you want to
> check for an error by using $!, you should set it to 0 before
> setting $(.

That _may_ work, but is not guaranteed by POSIX.  You cannot rely
on errno not being changed by a successful call.  The API you are
invoking may internally call other API that fail, and set errno,
but the outer API call expects and deals with that error condition.

In which case you will have a successful return, but a non-zero errno
value, even though you set errno to 0 before making the call.

Cheers,
-Jan



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About