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
Jan Dubois
September 13, 2011 12:55
RE: [perl #98934] set{u,g}id doesn't clear $! on success
Message ID:
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.


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