Updated in accordance with feedback from @narfbg

- Removed commented lists of constants from the three reference conventions,
  replacing each with the URLs at which more information can be found.
- Renamed a few constants to more closely reflect CodeIgniter conventions.
- Modified a couple of lines which were in violation of the CI Style Guide.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
diff --git a/application/config/constants.php b/application/config/constants.php
index 32a7159..dc84712 100644
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -80,104 +80,30 @@
 |
 | Used to indicate the conditions under which the script is exit()ing.
 | While there is no universal standard for error codes, there are some
-| broad conventions.  Three such conventions are presented below, for
+| broad conventions.  Three such conventions are mentioned below, for
 | those who wish to make use of them.  The CodeIgniter defaults were 
 | chosen for the least overlap with these conventions, while still
 | leaving room for others to be defined in future versions and user
-| applications.  The CodeIgniter values are defined last so you can 
-| set them to values used by any of the other conventions, and do so 
-| by name instead of value.
+| applications.
+| 
+| The three main conventions used for determining exit status codes
+| are as follows:
+|
+|    Standard C/C++ Library (stdlibc):
+|       http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
+|       (This link also contains other GNU-specific conventions)
+|    BSD sysexits.h:
+|       http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
+|    Bash scripting:
+|       http://tldp.org/LDP/abs/html/exitcodes.html
 |
 */
-
-/*
- * standard C/C++ library (stdlibc):
- */
-/*
-define('LIBC_EXIT_SUCCESS', 0);
-define('LIBC_EXIT_FAILURE', 1); // generic errors
-*/
-
-/* 
- * BSD sysexits.h 
- */
-/*
-define('SYS_EX_OK', 0); // successful termination
-define('SYS_EX_USAGE', 64); // command line usage error
-define('SYS_EX_DATAERR', 65); // data format error
-define('SYS_EX_NOINPUT', 66); // cannot open input
-define('SYS_EX_NOUSER', 67); // specified user unknown
-define('SYS_EX_NOHOST', 68); // specified host name unknown
-define('SYS_EX_UNAVAILABLE', 69); // service unavailable
-define('SYS_EX_SOFTWARE', 70); // internal software error
-define('SYS_EX_OSERR', 71); // system error (e.g., can't fork)
-define('SYS_EX_OSFILE', 72); // critical OS file missing
-define('SYS_EX_CANTCREAT', 73); // can't create (user) output file
-define('SYS_EX_IOERR', 74); // input/output error
-define('SYS_EX_TEMPFAIL', 75); // temporary failure; user is invited to retry
-define('SYS_EX_PROTOCOL', 76); // remote error in protocol
-define('SYS_EX_NOPERM', 77); // permission denied
-define('SYS_EX_CONFIG', 78); // configuration error
-*/
-
-/*
- * Bash scripting 
- */
-/*
-define('BASH_EXIT_SUCCESS', 0);
-define('BASH_EXIT_ERROR', 1);
-define('BASH_EXIT_BUILTIN_MISUSE', 2);
-define('BASH_EXIT_CANT_EXEC', 126);
-define('BASH_EXIT_CMD_NOT_FOUND', 127);
-define('BASH_EXIT_INVALID_EXIT', 128);
-define('BASH_EXIT_SIG_HUP', 129);
-define('BASH_EXIT_SIG_INT', 130);
-define('BASH_EXIT_SIG_QUIT', 131);
-define('BASH_EXIT_SIG_ILL', 132);
-define('BASH_EXIT_SIG_TRAP', 133);
-define('BASH_EXIT_SIG_ABRT', 134);
-define('BASH_EXIT_SIG_BUS', 135);
-define('BASH_EXIT_SIG_FPE', 136);
-define('BASH_EXIT_SIG_KILL', 137);
-define('BASH_EXIT_SIG_USR1', 138);
-define('BASH_EXIT_SIG_SEGV', 139);
-define('BASH_EXIT_SIG_USR2', 140);
-define('BASH_EXIT_SIG_PIPE', 141);
-define('BASH_EXIT_SIG_ALRM', 142);
-define('BASH_EXIT_SIG_TERM', 143);
-define('BASH_EXIT_SIG_STKFLT', 144);
-define('BASH_EXIT_SIG_CHLD', 145);
-define('BASH_EXIT_SIG_CONT', 146);
-define('BASH_EXIT_SIG_STOP', 147);
-define('BASH_EXIT_SIG_TSTP', 148);
-define('BASH_EXIT_SIG_TTIN', 149);
-define('BASH_EXIT_SIG_TTOU', 150);
-define('BASH_EXIT_SIG_URG', 151);
-define('BASH_EXIT_SIG_XCPU', 152);
-define('BASH_EXIT_SIG_XFSZ', 153);
-define('BASH_EXIT_SIG_VTALRM', 154);
-define('BASH_EXIT_SIG_PROF', 155);
-define('BASH_EXIT_SIG_WINCH', 156);
-define('BASH_EXIT_SIG_IO', 157);
-define('BASH_EXIT_SIG_PWR', 158);
-define('BASH_EXIT_SIG_SYS', 159);
-*/
-/*
- * BASH_EXIT_OUTOFRANGE would be 255, and mean an exit status code beyond 
- * the range of 0-255 was given.  However, this code CANNOT BE USED IN PHP,
- * so it isn't actually defined, even in a comment.
- */
-
-/*
- * CodeIgniter defaults
- */
 define('EXIT_SUCCESS', 0); // no errors
-define('EXIT_FAILURE', 1); // generic error
+define('EXIT_ERROR', 1); // generic error
 define('EXIT_CONFIG', 3); // configuration error
-define('EXIT_404', 4); // file not found; convenience value
-define('EXIT_UNK_FILE', 4); // file not found
-define('EXIT_UNK_CLASS', 5); // unknown class
-define('EXIT_UNK_MEMBER', 6); // unknown class member
+define('EXIT_UNKNOWN_FILE', 4); // file not found
+define('EXIT_UNKNOWN_CLASS', 5); // unknown class
+define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
 define('EXIT_USER_INPUT', 7); // invalid user input
 define('EXIT_DATABASE', 8); // database error
 define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
diff --git a/index.php b/index.php
index a52a021..c6314da 100755
--- a/index.php
+++ b/index.php
@@ -68,7 +68,7 @@
 	default:
 		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
 		echo 'The application environment is not set correctly.';
-		exit(1); // EXIT_* constants not yet defined; 1 is EXIT_FAILURE, a generic error.
+		exit(1); // EXIT_* constants not yet defined; 1 is EXIT_ERROR, a generic error.
 }
 
 /*
diff --git a/system/core/Common.php b/system/core/Common.php
index 479f0da..e11668d 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -177,7 +177,7 @@
 			// self-referencing loop with the Exceptions class
 			set_status_header(503);
 			echo 'Unable to locate the specified class: '.$class.'.php';
-			exit(EXIT_UNK_CLASS);
+			exit(EXIT_UNKNOWN_CLASS);
 		}
 
 		// Keep track of what we just loaded
@@ -377,13 +377,13 @@
 			$exit_status = $status_code + EXIT__AUTO_MIN;
 			if ($exit_status > EXIT__AUTO_MAX)
 			{
-				$exit_status = EXIT_FAILURE;
+				$exit_status = EXIT_ERROR;
 			}
 			$status_code = 500;
 		}
 		else
 		{
-			$exit_status = EXIT_FAILURE;
+			$exit_status = EXIT_ERROR;
 		}
 		
 		$_error =& load_class('Exceptions', 'core');
@@ -411,7 +411,7 @@
 	{
 		$_error =& load_class('Exceptions', 'core');
 		$_error->show_404($page, $log_error);
-		exit(EXIT_UNK_FILE);
+		exit(EXIT_UNKNOWN_FILE);
 	}
 }
 
@@ -531,13 +531,16 @@
 
 		$server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
 
-		if (strpos(php_sapi_name(), 'cgi') === 0)
+		if ( ! headers_sent())
 		{
-			if (!headers_sent()) header('Status: '.$code.' '.$text, TRUE);
-		}
-		else
-		{
-			if (!headers_sent()) header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code);
+			if (strpos(php_sapi_name(), 'cgi') === 0)
+			{
+				header('Status: '.$code.' '.$text, TRUE);
+			}
+			else
+			{
+				header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code);
+			}
 		}
 	}
 }
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index 423387f..9c68d06 100644
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -117,7 +117,7 @@
 		}
 
 		echo $this->show_error($heading, $message, 'error_404', 404);
-		exit(EXIT_UNK_FILE);
+		exit(EXIT_UNKNOWN_FILE);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 25863ea..bd32965 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -142,7 +142,7 @@
 		if ($data !== NULL)
 		{
 			echo $data;
-			exit(EXIT_SUCCESS);
+			exit;
 		}
 
 		// Flush 1MB chunks of data
@@ -152,7 +152,7 @@
 		}
 
 		fclose($fp);
-		exit(EXIT_SUCCESS);
+		exit;
 	}
 }
 
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 9a56013..1bc365c 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -290,7 +290,7 @@
 
 		$trace = debug_backtrace();
 		_exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']);
-		exit(EXIT_UNK_MEMBER);
+		exit(EXIT_UNKNOWN_METHOD);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index e150c13..a6048cb 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -171,7 +171,7 @@
 		header('Content-Type: text/xml');
 		header('Content-Length: '.strlen($payload));
 		echo $payload;
-		exit(EXIT_SUCCESS);
+		exit;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst
index 1d6f812..441cedb 100644
--- a/user_guide_src/source/general/errors.rst
+++ b/user_guide_src/source/general/errors.rst
@@ -49,7 +49,7 @@
 the HTTP status code will be set to 500, and the exit status code will
 be set to ``$status_code + EXIT__AUTO_MIN``. If that value is larger than
 ``EXIT__AUTO_MAX``, or if ``$status_code`` is 100 or higher, the exit
-status code will be set to ``EXIT_FAILURE``. You can check in 
+status code will be set to ``EXIT_ERROR``. You can check in 
 *application/config/constants.php* for more detail.
 
 show_404()
@@ -67,7 +67,7 @@
 	application/errors/error_404.php
 
 The function expects the string passed to it to be the file path to the
-page that isn't found. The exit status code will be set to ``EXIT_UNK_FILE``.
+page that isn't found. The exit status code will be set to ``EXIT_UNKNOWN_FILE``.
 Note that CodeIgniter automatically shows 404 messages if controllers are
 not found.