title: Return Code on failure. Positive or negative?
body: <p>a C-programm can fail to execute under special circumstances in Linux. 
  Example: You allocate some space and the OS denies it.</p>
  
  <pre><code>char *buffer = (char *) malloc(1024);
  if (buffer == NULL)
      return ENOMEM;
  </code></pre>
  
  <p>This failure is marked by the return code which is delivered to the OS.</p>
  
  <ul>
  <li>A return code of 0 (EXIT_SUCCESS) is marked as a successful execution.</li>
  <li>A return code which is not 0, is marked as a failure. </li>
  </ul>
  
  <p>So my question is, <strong>what is the convention, when a program detects an error.
  Should it return a positive or a negative return code ?</strong></p>
  
  <p>My professor told me in UNIX/Linux allways to return a negative error code. But the errno-Codes are all positive integers. Also the define-Statement of EXIT_FAILURE in  is 1, a positive integer. 
  So should my code look like this:</p>
  
  <pre><code>char *buffer = (char *) malloc(1024);
  if (buffer == NULL)
      return -ENOMEM;
  </code></pre>
  
  <p>or like the code above? I know from Linux-Kernel-Modules that in most cases they return a negative error code on failure.</p>
  
  <p>Thanks for helping.</p>