title: How to check the value of errno?
body: <p>I am using a system call and in case it fails, I need to do different things for different errnos.</p>
  
  <p>I need to write code that looks something like this:</p>
  
  <pre><code>int res;
  res = systemCall();
  if (res == -1)
  {
      if (errno == ENOMSG)
      {
          doSomething();
      }
      else
      {
          doSomethingElse();
      }
  }
  </code></pre>
  
  <p>perror doesn't help, because it only prints the value.</p>
  
  <p>As for strerro - if it is what I need, I am not suer how to use it, because <a href="http://man7.org/linux/man-pages/man3/strerror.3.html" rel="noreferrer">here</a> it says that the actual string is not the same as the error. Quote from the man page: "(For example, if errnum is EINVAL, the returned description will be "Invalid argument")".</p>
  
  <p>I am using Linux.
  System calls: msgsend and msgrcv (<a href="https://linux.die.net/man/2/msgrcv" rel="noreferrer">https://linux.die.net/man/2/msgrcv</a>). I am not sure what C libraries you are asking about.</p>
  
  <p>I see I didn't explain myself well.</p>
  
  <p>Is the statement if (errno == ENOMSG) valid? Is there such a variable errno? Basically my question is: What should go in the <code>if</code> statement in order to test the errno?</p>