script exit code to system() c function
Hi guys,
Consider the following code: Code:
... This is a cgi script if it matters... What am I missing? Thx |
A quick google turned up as far as I can tell that you should run the result through WEXITSTATUS
Code:
#include <stdlib.h> |
thanks aspire1!
It works, can's say "as expected", but it works :). thanks again |
look at man waitpid maybe.
the lower 8 bits from a system is a bitmask. these signify how the process exited e.g. a signal. the actual return code you need to right shift by 8. this may be of interest to you, observe, simplified from aspire: Code:
#include <sys/wait.h> if i put the above through the preprocessor: Code:
gcc -E 1.c |
thanks bigearsbilly, it worked as aspire suggested.
when i said "not as expected" i meant that i asumed system returns the unaltered exit status of the command. meanwhile i read the man page of system and got a better understanding of it. your comment is very interesting. i never used gcc to study code. i'll keep that in mind. |
All times are GMT -5. The time now is 01:59 AM. |