commit 9fa0f962faf54b82ef26c265f272dcec7639a0e1
parent 9f5a552f75f54ce14fb0b6fb2d1b91a0ccfc56e8
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Sun, 6 Oct 2024 17:02:48 +0200
replace wait_nohang with waidpid (part 2)
Diffstat:
6 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/runit-init.c b/src/runit-init.c
@@ -7,6 +7,7 @@
#include "sig.h"
#include "open.h"
#include "error.h"
+#include <sys/wait.h>
#define USAGE " 0|6"
#define FATAL "init: fatal: "
diff --git a/src/runit.c b/src/runit.c
@@ -13,6 +13,7 @@
#include "coe.h"
#include "ndelay.h"
#include "wait.h"
+#include <sys/wait.h>
#include "open.h"
/* #define DEBUG */
@@ -145,10 +146,10 @@ int main (int argc, const char * const *argv, char * const *envp) {
sig_block(sig_int);
while (read(selfpipe[0], &ch, 1) == 1) {}
- while ((child =wait_nohang(&wstat)) > 0)
+ while ((child =waitpid( -1, &wstat, WNOHANG )) > 0)
if (child == pid) break;
if (child == -1) {
- strerr_warn2(WARNING, "wait_nohang, pausing: ", &strerr_sys);
+ strerr_warn2(WARNING, "waitpid, pausing: ", &strerr_sys);
sleep(5);
}
@@ -238,7 +239,7 @@ int main (int argc, const char * const *argv, char * const *envp) {
kill(pid, sig_term);
i =0;
while (i < 5) {
- if ((child =wait_nohang(&wstat)) == pid) {
+ if ((child =waitpid( -1, &wstat, WNOHANG )) == pid) {
#ifdef DEBUG
strerr_warn2(WARNING, "stage 2 terminated.", 0);
#endif
@@ -247,7 +248,7 @@ int main (int argc, const char * const *argv, char * const *envp) {
}
if (child) continue;
if (child == -1)
- strerr_warn2(WARNING, "wait_nohang: ", &strerr_sys);
+ strerr_warn2(WARNING, "waitpid: ", &strerr_sys);
#ifdef DEBUG
strerr_warn2(WARNING, "waiting...", 0);
#endif
diff --git a/src/runsv.c b/src/runsv.c
@@ -15,6 +15,7 @@
#include "open.h"
#include "lock.h"
#include "wait.h"
+#include <sys/wait.h>
#include "fd.h"
#include "buffer.h"
#include "fmt.h"
@@ -548,7 +549,7 @@ int main(int argc, char **argv) {
int child;
int wstat;
- child =wait_nohang(&wstat);
+ child =waitpid( -1, &wstat, WNOHANG );
if (!child) break;
if ((child == -1) && (errno != error_intr)) break;
if (child == svd[0].pid) {
diff --git a/src/runsvdir.c b/src/runsvdir.c
@@ -9,6 +9,7 @@
#include "strerr.h"
#include "error.h"
#include "wait.h"
+#include <sys/wait.h>
#include "env.h"
#include "open.h"
#include "pathexec.h"
@@ -202,7 +203,7 @@ int main(int argc, char **argv) {
for (;;) {
/* collect children */
for (;;) {
- if ((pid =wait_nohang(&wstat)) <= 0) break;
+ if ((pid =waitpid( -1, &wstat, WNOHANG )) <= 0) break;
for (i =0; i < svnum; i++) {
if (pid == sv[i].pid) {
/* runsv has gone */
diff --git a/src/svlogd.c b/src/svlogd.c
@@ -20,6 +20,7 @@
#include "sig.h"
#include "env.h"
#include "fd.h"
+#include <sys/wait.h>
#include "wait.h"
#include "error.h"
#include "sgetopt.h"
@@ -624,7 +625,7 @@ void sig_child_handler(void) {
int pid, l;
if (verbose) strerr_warn2(INFO, "sigchild received.", 0);
- while ((pid =wait_nohang(&wstat)) > 0)
+ while ((pid =waitpid( -1, &wstat, WNOHANG )) > 0)
for (l =0; l < dirn; ++l)
if (dir[l].ppid == pid) {
dir[l].ppid =0;
diff --git a/src/wait.h b/src/wait.h
@@ -4,7 +4,6 @@
#define WAIT_H
extern int wait_pid();
-extern int wait_nohang();
extern int wait_stop();
extern int wait_stopnohang();