This sorta does it. You'll have to modify it heavily for your use.
Code:
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
int main( int argc, char *argv[] )
{
int a;
char cmd[256];
for( a = 1; a < argc; a++ )
{
pid_t cpid;
cpid = fork();
switch(cpid)
{
case -1: // uh-oh
{
printf("Unable to claim system resources.\n");
break;
}
case 0: // i am the child proc
{
char cmd[256];
sprintf(cmd, "ping -c 1 -w 2 %s", argv[a]);
system(cmd);
_exit(0);
break;
}
default: // all your child process are belong to us
{
int status;
//waitpid(cpid, &status, 0);
break;
}
}
}
return 0;
}
And in a scriptable (bash) format:
Code:
#!/bin/bash
IPS="172.26.12.1 172.26.26.2"
for ip in $IPS;
do
ping -w 2 $ip&
done
Enjoy