From a8abc24ce9dfa0bf85eeb405f98e29a3c76e647b Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 11 Nov 2023 19:59:09 +0100 Subject: wait instead of waitpid --- rpt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rpt.c b/rpt.c index 298f60e..1d1f0cb 100644 --- a/rpt.c +++ b/rpt.c @@ -96,13 +96,13 @@ exec_child(char **argv) } void -wait_child(pid_t pid, void (*handle_error_f)(int status)) +wait_child(void (*handle_error_f)(int status)) { - int exit_status = 0; + int wstatus; - waitpid(pid, &exit_status, 0); + wait(&wstatus); - handle_error_f(exit_status); + handle_error_f(WEXITSTATUS(wstatus)); } void @@ -119,10 +119,10 @@ invoke_cmd(char **argv, void (*handle_error_f)(int status)) if (pid == 0) exec_child(argv); else - wait_child(pid, handle_error_f); + wait_child(handle_error_f); } -/* Invoke the executable *ARGV COUNT times, passing it the rest of ARG as +/* Invoke the executable *ARGV COUNT times, passing it the rest of ARGV as arguments. Call HANDLE_ERROR_F between each process. */ void repeat_cmd(char **argv, long count, void (*handle_error_f)(int status)) -- cgit v1.2.3