int bar_cb (coproc_t *c, void *arg) { while (!death) { if (coproc_yield (c) < 0) return -1; } return 0; }
int foo_cb (coproc_t *c, void *arg) { int n; /* number of times to yield */ ok (arg && *(int *)arg >= 0 && *(int *)arg <= 16, "coproc args are valid"); n = *(int *)arg; while (n > 0) { if (coproc_yield (c) < 0) return -1; n--; } return n; }
int flux_sleep_on (flux_t h, struct flux_match match) { struct dispatch *d = dispatch_get (h); int rc = -1; if (!d->current || !d->current->coproc) { errno = EINVAL; goto done; } flux_msg_handler_t *w = d->current; copy_match (&w->wait_match, match); if (zlist_append (d->waiters, w) < 0) oom (); if (coproc_yield (w->coproc) < 0) goto done; rc = 0; done: return rc; }
/* Handler will yield if it segfaulted; return if not. */ void sigsegv_handler (int sig) { coproc_yield (co); }