#include #include #include #include #define NUM_THREADS 4 int main(int argc, char **argv) { int pid, ret, i; char cmd[1024]; if (argc != 2) { fprintf(stderr, "Usage: %s [hostname]\n", argv[0]); exit(-1); } i = 0; do { pid = fork(); i++; } while (pid && i < NUM_THREADS); if (pid) { /* Parent */ for (i = 0; i < NUM_THREADS; i++) wait(&ret); /* Wait for the child to join */ } else { snprintf(cmd, 1024, "ssh %s hostname", argv[1]); system(cmd); } return 0; }