aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-04-11 13:49:56 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-04-11 13:49:56 +0000
commit520c7f76ff740daaeba5718ce724a4ca2c3bb221 (patch)
tree82a9b69e32e963575a230962ca6fd1d44c27936a
parentca7c39c593b3d3fab1df1df59efddd4d42a9678d (diff)
downloadexecline-520c7f76ff740daaeba5718ce724a4ca2c3bb221.tar.gz
Minor code cleanups
-rw-r--r--src/execline/trap.c2
-rw-r--r--src/execline/wait.c17
2 files changed, 10 insertions, 9 deletions
diff --git a/src/execline/trap.c b/src/execline/trap.c
index ba1b25a..d36e980 100644
--- a/src/execline/trap.c
+++ b/src/execline/trap.c
@@ -125,7 +125,7 @@ int main (int argc, char const **argv, char const *const *envp)
if (!pids[SKALIBS_NSIG]) strerr_diefu2sys(111, "spawn ", argv[argc1 + 1]) ;
loop:
- if (iopause_g(&x, 1, 0) < 0) strerr_diefu1sys(111, "iopause") ;
+ if (iopause_g(&x, 1, 0) == -1) strerr_diefu1sys(111, "iopause") ;
for (;;)
{
int r = selfpipe_read() ;
diff --git a/src/execline/wait.c b/src/execline/wait.c
index d30ae68..26ac5d3 100644
--- a/src/execline/wait.c
+++ b/src/execline/wait.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <execline/config.h>
+#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
@@ -15,6 +15,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
+#include <execline/config.h>
#include <execline/execline.h>
#define USAGE "wait [ -I | -i ] [ -a | -o ] [ -r | -t timeout ] { pids... } [ prog... ]"
@@ -43,7 +44,7 @@ static int wait_one (pid_t *pid)
{
int wstat = 0 ;
*pid = wait(&wstat) ;
- if (*pid < 0)
+ if (*pid == -1)
{
if (errno != ECHILD) strerr_diefu1sys(111, "wait") ;
else return -1 ;
@@ -58,7 +59,7 @@ static int wait_one_from_list (pid_t *pids, unsigned int n, pid_t *pid)
int wstat ;
pid_t r = wait(&wstat) ;
unsigned int i = 0 ;
- if (r < 0)
+ if (r == -1)
{
if (errno != ECHILD) strerr_diefu1sys(111, "wait") ;
else return -1 ;
@@ -76,7 +77,7 @@ static int wait_one_from_list (pid_t *pids, unsigned int n, pid_t *pid)
static int wait_one_nohang (pid_t *pids, unsigned int *n, int *wstat)
{
pid_t r = wait_nohang(wstat) ;
- if (r < 0 && errno != ECHILD) strerr_diefu1sys(111, "wait") ;
+ if (r == -1 && errno != ECHILD) strerr_diefu1sys(111, "wait") ;
(void)pids ;
(void)n ;
return r ;
@@ -118,7 +119,7 @@ static int wait_with_timeout (pid_t *pids, unsigned int n, pid_t *returned, ac_f
iopause_fd x = { .fd = selfpipe_init(), .events = IOPAUSE_READ } ;
pid_t special = pids[n-1] ;
int e = special ? -1 : 0 ;
- if (x.fd < 0) strerr_diefu1sys(111, "create selfpipe") ;
+ if (x.fd == -1) strerr_diefu1sys(111, "create selfpipe") ;
if (!selfpipe_trap(SIGCHLD)) strerr_diefu1sys(111, "trap SIGCHLD") ;
tain_now_set_stopwatch_g() ;
tain_add_g(tto, tto) ;
@@ -139,7 +140,7 @@ static int wait_with_timeout (pid_t *pids, unsigned int n, pid_t *returned, ac_f
if (justone || !n) goto endloop ;
}
r = iopause_g(&x, 1, tto) ;
- if (r < 0) strerr_diefu1sys(111, "iopause") ;
+ if (r == -1) strerr_diefu1sys(111, "iopause") ;
else if (!r)
{
if (!strict) { e = -1 ; break ; }
@@ -231,9 +232,9 @@ int main (int argc, char const **argv)
wait_from_list(pids, n) : /* wait 2 3 4 / wait { 2 3 4 }*/
wait_all() ; /* wait / wait { } */
}
- if (!hasblock) return e >= 0 ? e : 127 ;
+ if (!hasblock) _exit(e >= 0 ? e : 127) ;
if (!(wgolb & GOLB_JUSTONE)) xexec0(argv + argc1 + 1) ;
- if (e < 0) xmexec0_n(argv + argc1 + 1, "?\0!", 4, 2) ;
+ if (e == -1) xmexec0_n(argv + argc1 + 1, "?\0!", 4, 2) ;
{
char fmt[4 + UINT_FMT + PID_FMT] = "?=" ;