rendered paste body if ( wait_comp_flag ) {
int ready = 0, count=0, exited=0;
hal_comp_t *comp = NULL;
while(!ready && !exited) {
/* sleep for 10mS */
struct timespec ts = {0, 10 * 1000 * 1000};
nanosleep(&ts, NULL);
/* check for program ending */
retval = waitpid( pid, &status, WNOHANG );
if ( retval < 0 ) {
if (count >= 100) {
fprintf(stderr, "\n");
}
rtapi_print_msg(RTAPI_MSG_ERR,
"HAL:%d: ERROR: waitpid(%d) failed\n", linenumber, pid);
return -1;
}
if ( retval > 0 ) {
exited = 1;
}
/* check for program becoming ready */
rtapi_mutex_get(&(hal_data->mutex));
comp = halpr_find_comp_by_name(new_comp_name);
if(comp && comp->ready) {
ready = 1;
}
rtapi_mutex_give(&(hal_data->mutex));
/* pacify the user */
count++;
if(count == 100) {
fprintf(stderr, "Waiting for component '%s' to become ready.",
new_comp_name);
fflush(stderr);
} else if(count > 100 && count % 10 == 0) {
fprintf(stderr, ".");
fflush(stderr);
}
}
if (count >= 100) {
fprintf(stderr, "\n");
}
if (ready) {
rtapi_print_msg(RTAPI_MSG_INFO, "Component '%s' ready\n", new_comp_name);
} else {
rtapi_print_msg(RTAPI_MSG_ERR,
"HAL:%d: ERROR: %s exited without becoming ready\n", linenumber, prog_name);
return -1;
}
}