wait
returning >= 0
tells you a child process has terminated (and that calling wait
didn’t fail), but it does not tell you whether that process terminated successfully or not (or if it was signalled).
But, here, looking at your code, it’s fairly obvious the program does care about whether the child process that terminated did so successfully or not:
fprintf( stderr,"Child failed. Killing all running children.\n");
So, the program needs to do further tests on the status
structure that was populated by wait
:
WIFEXITED(status)
: did the process exit normally? (as opposed to being signalled).WEXITSTATUS(status) == 0
: did the process exit with exit code 0 (aka “success”). For more information, see: Meaning of exit status 1 returned by linux command.
Related Posts:
- What is `S_ISREG()`, and what does it do?
- Why does ENOENT mean “No such file or directory”?
- What is the meaning of *nix?
- What can cause a “Resource temporarily unavailable” on sock send() command
- Bind failed: Address already in use
- How to make parent wait for all child processes to finish?
- malloc(): memory corruption
- Where is the
header file on Linux? Why can’t I find ? - C fopen vs open
- Where does linux store my syslog?
- How to know what the ‘errno’ means?
- How to use shared memory with Linux in C
- What is newline character — ‘\n’
- What are file descriptors, explained in simple terms?
- How do I grep recursively?
- What are .a and .so files?
- How to print pthread_t
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- SSH using python script
- What is a bus error? Is it different from a segmentation fault?
- Does connect() block for TCP socket?
- How to cat <
> a file containing code? - where does stdio.o live in linux machine?
- Extract file basename without path and extension in bash
- Display value found at given address gdb
- How to download a file from server using SSH?
- How to initialize array to 0 in C?
- Sign extend a nine-bit number in C
- Cache Simulator in C
- make: Nothing to be done for `all’
- expected expression before ‘{‘ token
- Setting std=c99 flag in GCC
- C Vector/ArrayList/LinkedList
- Convert char array to a int number in C
- What is the difference between %f and %lf in C?
- What is stdin in C language?
- error: ‘for’ loop initial declarations are only allowed in C99 mode [duplicate]
- c – warning: implicit declaration of function ‘printf’
- error: aggregate value used where an integer was expected
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- Implementing shell in C and need help handling input/output redirection
- What does `set -x` do?
- Portable way to check if directory exists [Windows/Linux, C]
- How to use EOF to run through a text file in C?
- Incorrect checksum for freed object on malloc
- Is there any simple way to benchmark Python script?
- Simple way to check if a string contains another string in C?
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Segmentation fault (core dumped) due to fgets – I think
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- How to convert integer to char in C?
- Is there a good Valgrind substitute for Windows?
- Difference between “move” and “li” in MIPS assembly language
- Writing a simple shell in C using fork/execvp
- What is the difference between array and enum in C ?
- Undefined reference to main – collect2: ld returned 1 exit status
- Implementation of multiple pipes in C
- How can one see content of stack with GDB?
- What does the term “empty loop” refer to exactly in C and C++?
- Using ls to list directories and their total sizes
- What integer hash function are good that accepts an integer hash key?
- Proper way to empty a C-String
- X86 assembly – Handling the IDIV instruction
- Pause screen at program completion in C
- Is there an alternative sleep function in C to milliseconds?
- Difference between fgets and fscanf?
- Syntax error near unexpected token ‘then’
- Can’t understand the working of getint() in C as per K&R
- Lua – Number to string behaviour
- What do the dup() and dup2() systems really do?
- Reading in double values with scanf in c
- Reaching EOF with fgets
- Realloc Invalid Pointer in C
- What tools are there for functional programming in C?
- typedef fixed length array
- “-bash: gcc: command not found” using cygwin when compiling c?
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- What are the differences between if, else, and else if?
- strtok segmentation fault
- Invalid write of size 1
- How to solve static declaration follows non-static declaration in GCC C code?
- realloc(): invalid next size when reallocating to make space for strcat on char *
- C Error: declaration shadows a local variable — Won’t let me repeatedly replace the value of my float variable
- MIPS to C Translation
- Pointer to 2D arrays in C
- Pointer to a string in C?
- gdb: No symbol “i” in current context
- Cross Platform C library for GUI Apps?
- Pre increment vs Post increment in array
- “Nothing to be done for makefile” message
- What is the difference between signed and unsigned int
- How do I do ‘mount –bind’ in /etc/fstab?
- Meaning of directories on Unix and Unix like systems
- How to get pid of just started process
- Can you have more than one ~/.ssh/config file?
- How to disable everything in crontab -l?
- How to sort ps output by process start time?