X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fswarm.git;a=blobdiff_plain;f=src%2Fslave.c;h=622bc7b443cf48bb98fe026a6fead4e57a23f1fa;hp=65e11c82c2b0ac7c31c9e8c5281c962e47a8069e;hb=HEAD;hpb=4e2127d6576cea3f54c619d0bb20a22006567206 diff --git a/src/slave.c b/src/slave.c index 65e11c8..622bc7b 100644 --- a/src/slave.c +++ b/src/slave.c @@ -35,13 +35,15 @@ void Slave_cleanup(); void Slave_main(Options * o) { + //fprintf(stderr, "%d\n", o->nCPU); + setbuf(stdin, NULL); setbuf(stdout, NULL); setbuf(stderr, NULL); dup2(fileno(stdout), fileno(stderr)); // yes, this works, apparently - slave = (Slave*)(calloc(o->nCPU, sizeof(slave))); + slave = (Slave*)(calloc(o->nCPU, sizeof(Slave))); atexit(Slave_cleanup); @@ -68,7 +70,8 @@ void Slave_main(Options * o) fgets(name, sizeof(name), stdin); name[strlen(name)-1] = '\0'; - //log_print(2, "Slave_main", "Got name %s", name); + //log_print(LOGINFO, "Slave_main", "Started remote swarm \"%s\"", name); + fprintf(stdout, "%d\n", o->nCPU); //log_print(2, "Slave_main", "Wrote nCPU %d", o->nCPU); @@ -160,30 +163,12 @@ void Slave_loop(Options * o) if (i >= o->nCPU) error("Slave_loop", "No child matches pid %d", p); - - - fprintf(stderr,"Unexpected exit of slave %s:%d", name, i); - if (WIFSIGNALED(s)) - { - int sig = WTERMSIG(s); - fprintf(stderr," due to %s", strsignal(sig)); - if (sig == SIGKILL) - { - fprintf(stderr," - %s committing suicide\n", name); - kill(getpid(), sig); - } - } - else - { - fprintf(stderr," return code %d.", s); - } + sigchld_respond(s, name, i); // cancel any tasks at the master for this slave - static int len = -1; - if (len < 0) - len = strlen(o->end); - write(slave[i].out, o->end, len); + + write(slave[i].out, SHELL_OUTPUT_FINISHED, SHELL_OUTPUT_FINISHED_LENGTH); Slave_shell(i, o->shell);