This is a base-line attempt at separating errors from the child from the
ones from script itself ‒ 125 is the general-purpose code in POSIX
utilities that exec() (with 126 being ENOEXEC and 127 ‒ ENOENT)
---
Please keep me in CC, as I'm not subscribed.

 usr.bin/script/script.1 | 6 ++----
 usr.bin/script/script.c | 6 +++---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1
index aa8bb2790..2ce483b97 100644
--- a/usr.bin/script/script.1
+++ b/usr.bin/script/script.1
@@ -80,10 +80,8 @@ or control-D
 .Pq Ql ^D
 will exit most interactive shells).
 .Nm
-will exit with the status of 0 unless any of its child
-processes fail, in which case,
-.Nm
-will return 1.
+will exit with the status of the shell,
+or 125 if it couldn't execute it.
 .Pp
 Certain interactive commands, such as
 .Xr vi 1 ,
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index fd2829033..1c2db608d 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -119,7 +119,7 @@ main(int argc, char *argv[])
                default:
                        fprintf(stderr, "usage: %s [-a] [-c command] [file]\n",
                            __progname);
-                       exit(1);
+                       exit(125);
                }
        argc -= optind;
        argv += optind;
@@ -206,7 +206,7 @@ void
 finish(int signo)
 {
        int save_errno = errno;
-       int status, e = 1;
+       int status, e = 125;
        pid_t pid;
 
        while ((pid = wait3(&status, WNOHANG, 0)) > 0) {
@@ -335,7 +335,7 @@ fail(void)
 {
 
        (void)kill(0, SIGTERM);
-       done(1);
+       done(125);
 }
 
 void
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature

Reply via email to