about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-08-22 15:10:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-08-22 15:10:36 +0000
commit523036ef1e6e4bd7047ec21a6e68b7508569db91 (patch)
tree2612ec7431849a5b5d2b8b926dc8479a0f02e9e4
parent6ead33f5fe46f38a63532daa95ec96bd39ecbfd8 (diff)
downloadexecline-523036ef1e6e4bd7047ec21a6e68b7508569db91.tar.gz
execline-523036ef1e6e4bd7047ec21a6e68b7508569db91.tar.xz
execline-523036ef1e6e4bd7047ec21a6e68b7508569db91.zip
More conversion to xpathexec, make exit code change consistent across binaries
-rw-r--r--NEWS2
-rw-r--r--doc/exitcodes.html11
-rw-r--r--doc/index.html5
-rw-r--r--doc/upgrade.html2
-rw-r--r--src/execline/background.c3
-rw-r--r--src/execline/pipeline.c3
6 files changed, 23 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 3a1be32..2459983 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,9 @@ Changelog for execline.
 
 In 2.3.0.2
 ----------
+
  - Optimization release to go with skalibs-2.6.0.0
+ - xpathexec* exit codes changed.
 
 
 In 2.3.0.1
diff --git a/doc/exitcodes.html b/doc/exitcodes.html
index 7463bd1..51902f1 100644
--- a/doc/exitcodes.html
+++ b/doc/exitcodes.html
@@ -94,5 +94,16 @@ a scion of <em>C</em> had problems. </li>
  <li> Exact information is reported in the common case. </li>
 </ul>
 
+<h2> Summary of common exit codes for execline programs </h2>
+
+<ul>
+ <li> 0: success. This code is rarely encountered, because most execline
+programs chainload into something else when they succeed, instead of exiting 0. </li>
+ <li> 100: wrong usage </li>
+ <li> 111: system call failed </li>
+ <li> 126: unable to chainload into another program (any other error than ENOENT) </li>
+ <li> 127: unable to chainload into another program (executable not found) </li>
+</ul>
+
 </body>
 </html>
diff --git a/doc/index.html b/doc/index.html
index d39e3bd..929dbab 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -110,8 +110,11 @@ to your installation: the shebang lines for your system might be something like
 
 <p>
  All these commands exit 111 if they encounter a temporary error, and
-100 if they encounter a permanent error - such as a misuse.
+100 if they encounter a permanent error - such as a misuse. They exit
+127 if they're trying to execute into a program and cannot find it, and
+126 if they fail to execute into a program for another reason.
 </p>
+
 <p>
  (Script parser / launcher)
 </p>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index a954d63..d64d75d 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -22,6 +22,8 @@
 
 <ul>
  <li> skalibs dependency bumped to 2.6.0.0 </li>
+ <li> Commands now exit 127 (not found) or 126 (other error) if
+they cannot exec into a program they're supposed to. </li>
  <li> The <a href="import.html">import</a> command will likely
 disappear <em>very soon</em>. Please switch to
 <a href="importas.html">importas</a> as soon as possible! </li>
diff --git a/src/execline/background.c b/src/execline/background.c
index dc7a01a..e8def5b 100644
--- a/src/execline/background.c
+++ b/src/execline/background.c
@@ -2,6 +2,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#include <errno.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/strerr2.h>
 #include <skalibs/env.h>
@@ -46,7 +47,7 @@ int main (int argc, char const **argv, char const *const *envp)
       case 0:
         PROG = "background (grandchild)" ;
         pathexec0_run(argv, envp) ;
-        strerr_dieexec(127, argv[0]) ;
+        strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
     }
   }
   else
diff --git a/src/execline/pipeline.c b/src/execline/pipeline.c
index 3017ea2..f61c35b 100644
--- a/src/execline/pipeline.c
+++ b/src/execline/pipeline.c
@@ -2,6 +2,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#include <errno.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/types.h>
 #include <skalibs/strerr2.h>
@@ -52,7 +53,7 @@ int main (int argc, char const **argv, char const *const *envp)
           fd_close(p[w]) ;
           if (fd_move(!w, p[!w]) < 0) strerr_diefu1sys(111, "fd_move") ;
           pathexec0_run(argv, envp) ;
-          strerr_dieexec(127, argv[0]) ;
+          strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
       }
       fd_close(p[!w]) ;
       fd = p[w] ;