tgrekov-pipex
HIVE pipex May 2024
Loading...
Searching...
No Matches
wait_all.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* wait_all.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/05/02 08:09:05 by tgrekov #+# #+# */
9/* Updated: 2024/05/02 10:50:17 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include <sys/wait.h>
21
31int wait_all(int *pids, int n, int override)
32{
33 int i;
34 int status;
35
36 i = 0;
37 while (i < n)
38 {
39 waitpid(pids[i], &status, 0);
40 if (WIFEXITED(status))
41 status = WEXITSTATUS(status);
42 else
43 status = 1;
44 i++;
45 }
46 if (override)
47 return (override);
48 return (status);
49}
int wait_all(int *pids, int n, int override)
Wait for first n processes in pids to change state and return the last process's exit code,...
Definition wait_all.c:31