I am using one system call in my c code
#include <sys/stat.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
int a = system("./test12.out"); //here if i give any wrong command
system("echo $?")
printf("system return is %d",a);
}
there isn't any test12.out file in my current folder. Now output is
sh: ./test12.out: No such file or directory
0
system return is 32512
Here is my shell command failed but how can I know that in my c code?
Edit:
So, can I do this
int main(int argc, char *argv[])
{
int a = system("dftg");
if(a == -1)
printf("some error has occured in that shell command");
else if (WEXITSTATUS(a) == 127)
printf("That shell command is not found");
else
printf("system call return succesfull with %d",WEXITSTATUS(a));
}