herr_t
ss_debug(void)
{
SS_ENTER(ss_debug, herr_t);
char line[1024], c[1];
int i, self;
if (sslib_g.command_fd<0) goto done;
self = ss_mpi_comm_rank(SS_COMM_WORLD);
while (1) {
/* Prompt */
if (isatty(sslib_g.command_fd))
fprintf(stderr, "SSlib-%d> ", self);
/* Read a line of input */
for (i=0, line[0]='\0'; (size_t)i+1<sizeof line; i++) {
ssize_t nread = read(sslib_g.command_fd, c, 1);
if (0==nread) {
if (0==i) strcpy(line, "detach");
break;
}
if (nread<0) SS_ERROR_FMT(CORRUPT, ("read failed from fd %d: %s", sslib_g.command_fd, strerror(errno)));
if ('\n'==*c) break;
line[i] = *c;
line[i+1] = '\0';
}
if (!strcmp(line, "detach")) break;
/* Process the command, but if an error occurs print it and continue as normal */
if (ss_debug_s(line)<0) SS_ERROR_NOW(FAILED, (""));
}
done:
SS_CLEANUP:
SS_LEAVE(0);
}