diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 11:10:07 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 11:10:07 +0000 |
commit | e5d4b64f13683c30ccdd333260febd57d2cdc2d7 (patch) | |
tree | 98ddb6b9b1b1812ae1d8ec2f418016b56e4ffcfd /src/libexecline/el_execsequence.c | |
parent | 5d0fa4b94d993a7a292554c7cce61be355e65b75 (diff) | |
download | execline-e5d4b64f13683c30ccdd333260febd57d2cdc2d7.tar.xz |
Adapt to skalibs 2.5.0.0 API
Diffstat (limited to 'src/libexecline/el_execsequence.c')
-rw-r--r-- | src/libexecline/el_execsequence.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/src/libexecline/el_execsequence.c b/src/libexecline/el_execsequence.c index d697f2e..42ef104 100644 --- a/src/libexecline/el_execsequence.c +++ b/src/libexecline/el_execsequence.c @@ -1,41 +1,23 @@ /* ISC license. */ -#include <sys/types.h> -#ifdef EXECLINE_OLD_VARNAMES -#include <skalibs/bytestr.h> -#endif +#include <unistd.h> #include <skalibs/djbunix.h> #include <skalibs/env.h> #include <skalibs/strerr2.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> void el_execsequence (char const *const *argv1, char const *const *argv2, char const *const *envp) { - if (!argv2[0]) - { - pathexec0_run(argv1, envp) ; - strerr_dieexec(111, argv1[0]) ; - } - else - { - size_t j = 2 ; - int wstat ; -#ifdef EXECLINE_OLD_VARNAMES - char fmt[UINT_FMT * 2 + 15] = "?=" ; -#else - char fmt[UINT_FMT + 1] = "?=" ; -#endif - 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]) ; - j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; -#ifdef EXECLINE_OLD_VARNAMES - byte_copy(fmt + j, 13, "LASTEXITCODE=") ; j += 13 ; - j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; -#endif - pathexec_r(argv2, envp, env_len(envp), fmt, j) ; - } + 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 (!argv2[0]) _exit(0) ; + j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; + pathexec_r(argv2, envp, env_len(envp), fmt, j) ; strerr_dieexec(111, argv2[0]) ; } |