summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-10-19 23:48:07 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-10-19 23:48:07 +0000
commit4af37be2e303014deb4f26bea3e954913002d1b8 (patch)
tree3a8d20d82ea1428ab3c3db606c4f8b7dba045b28
parentf3481b43bd892cde7b32af19a92393008257013e (diff)
downloadexecline-4af37be2e303014deb4f26bea3e954913002d1b8.tar.xz
bugfix: el_execsequence() needs to exec argv2 when posix_spawn() fails
-rw-r--r--NEWS1
-rw-r--r--src/libexecline/el_execsequence.c21
2 files changed, 17 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index e0492aa..c614ec0 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Changelog for execline.
In 2.5.3.0
----------
+ - Bugfixes.
- New configure option: --enable-pedantic-posix. This
makes the "cd" program a symbolic link to a "posix-cd" program
which is fully POSIX compliant. This makes distributions unable
diff --git a/src/libexecline/el_execsequence.c b/src/libexecline/el_execsequence.c
index 5adbe49..797aeb5 100644
--- a/src/libexecline/el_execsequence.c
+++ b/src/libexecline/el_execsequence.c
@@ -1,6 +1,8 @@
/* ISC license. */
+#include <string.h>
#include <unistd.h>
+
#include <skalibs/djbunix.h>
#include <skalibs/env.h>
#include <skalibs/strerr2.h>
@@ -10,13 +12,22 @@
void el_execsequence (char const *const *argv1, char const *const *argv2, char const *const *envp)
{
size_t j = 2 ;
- int wstat ;
char fmt[UINT_FMT + 1] = "?=" ;
pid_t pid = el_spawn0(argv1[0], argv1, envp) ;
- if (!pid) strerr_warnwu2sys("spawn ", argv1[0]) ;
- if (wait_pid(pid, &wstat) < 0)
- strerr_diefu2sys(111, "wait for ", argv1[0]) ;
+ if (!pid)
+ {
+ strerr_warnwu2sys("spawn ", argv1[0]) ;
+ memcpy(fmt+2, "127", 3) ;
+ j += 3 ;
+ }
+ else
+ {
+ int wstat ;
+ if (wait_pid(pid, &wstat) < 0)
+ strerr_diefu2sys(111, "wait for ", argv1[0]) ;
+ j += uint_fmt(fmt + j, wait_status(wstat)) ;
+ }
+ fmt[j++] = 0 ;
if (!argv2[0]) _exit(0) ;
- j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ;
xpathexec_r(argv2, envp, env_len(envp), fmt, j) ;
}