Find the answer to your Linux question:
Results 1 to 2 of 2
can anyone please help me out to find out how perror actually works??? In my client.c program i am receiving one error send: Bad file decriptor this is printed by ...
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    29

    detailed working of perror

    can anyone please help me out to find out how perror actually works???
    In my client.c program i am receiving one error
    send: Bad file decriptor
    this is printed by perror
    as the errno variable is set to 9 which is EBADF
    but i want to know from which file does perror seeks or maps this error??
    Or more properly how does the kernel maintains the error logs from where the perror prints the latest error.
    Please do reply as soon as possible.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    perror() simply takes the current errno value and output some sort of sensible string. It has nothing to do with error logs, and you are responsible for mapping the error to the file that caused it. Also, EBADF is a bad file descriptor error code, so perror() is simply telling you what you already know...

    From the man page for errno:
    Code:
           EBADF           Bad file descriptor (POSIX.1)
           EBADFD          File descriptor in bad state
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...