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)
---
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 7bc559377..28783961a 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 failed to start 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
No comments:
Post a Comment