[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: perror(), die aktuelle glibc und vielleicht nen bug



On Sat, 28 Sep 2002 16:23:02 +0200, michael loeffler wrote:

>   errno = 0; /* errno sollte sowiso auf null stehen, aber das hier um das
>               * nochmal zu betonen */
> 
>   perror("A"); /* das macht nun irgendwas daß nen Illegal Seek verursacht,
>                 * was imho nicht sein sollte */
> 
>   perror("B"); /* das zeigt nun den error "Illegal Seek" an, der vom
>                 * perror() davor, verursacht wurde */

> Und was den Verdacht, daß es sich um einen Bug handelt, noch verstärkt ist
> daß es unter SunOS funktioniert wie ich es erwartete. perror() hat dort
> errno unverändert gelassen.

man perror:
       Note
       that  errno  is undefined after a successful library call:
       this call may well change this variable,  even  though  it
       succeeds,  for  example  because  it  internally used some
       other library function that failed.  Thus,  if  a  failing
       call  is not immediately followed by a call to perror, the
       value of errno should be saved.

Der call perror("A") ist erfolgreich und hinterläßt damit einen
undefinierten errno. Das folgende perror("B") ist somit sinnfrei. 
Also errno speichern wie die man-page sagt.

  Reinhard



Reply to: