How do I read the nicinfo's exit status?

How do I read the nicinfo’s exit status?

[color=red]nicinfo : Display information about a network interface controller

Exit status:
0 Successful completion.
1 An error occurred.

follow is my code:

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
int status;
printf(“Welcome to the Momentics IDE\n”);
status=system(“nicinfo /dev/io-net/en1”);
printf(“status=%d\n”,status);
return EXIT_SUCCESS;
}

WEXITSTATUS(status) should help

From the docu: Use the WEXITSTATUS() macro to determine the low-order 8 bits of the termination status of the process.
(Note in the docu: 255 is equal to -1 on most systems, -1 can also be the shell, the command should run in, could not be executed,
generally this means something went wrong, but does not imply it was the command failed^^)

If you want the exit code as returned by nicinfo you need to use spawn() because with system() you’ll get the exit core returned by the shell.

This WEXITSTATUS() is return system() 's status, not nicinfo’s.
I wish know the network is link up or link down?

qnx.com/developers/docs/6.3. … fig_t.html

Check the “flags” member, the “NIC_FLAG_LINK_DOWN” bit.

And then of cause, /usr/include/sys/dcmd-io_net.h, the DCMD_IO_NET_GET_CONFIG command.

system():

Returns:
If command is NULL, system() returns zero if the shell isn’t present, or a nonzero value if the shell is present.
If command isn’t NULL, system() returns the result of invoking a copy of the shell. If the shell couldn’t be loaded, system() returns -1; otherwise, it returns the status of the specified command. Use the WEXITSTATUS() macro to determine the low-order 8 bits of the termination status of the process.

They say it returns the status of the specified command, i may misunderstood that, but thats what it reads