Skip to content

Commit

Permalink
Merge pull request flux-framework#6326 from grondo/bulk-exec-active-r…
Browse files Browse the repository at this point in the history
…anks

libsubprocess: fix bulk-exec reporting of active ranks
  • Loading branch information
mergify[bot] authored Sep 29, 2024
2 parents 459c3e2 + e854da5 commit 5736952
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/libsubprocess/bulk-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct idset *bulk_exec_active_ranks (struct bulk_exec *exec)

p = zlist_first (exec->processes);
while (p) {
if (flux_subprocess_state (p) == FLUX_SUBPROCESS_RUNNING) {
if (flux_subprocess_active (p)) {
int rank = flux_subprocess_rank (p);
if (rank >= 0 && idset_set (ranks, rank) < 0) {
goto error;
Expand Down
7 changes: 7 additions & 0 deletions src/common/libsubprocess/subprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,13 @@ flux_subprocess_state_t flux_subprocess_state (flux_subprocess_t *p)
return p->state;
}

bool flux_subprocess_active (flux_subprocess_t *p)
{
/* A subprocess is still active if it has not failed or completed.
*/
return (p && p->state != FLUX_SUBPROCESS_FAILED && !p->completed);
}

const char *flux_subprocess_state_string (flux_subprocess_state_t state)
{
switch (state)
Expand Down
5 changes: 5 additions & 0 deletions src/common/libsubprocess/subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ flux_subprocess_state_t flux_subprocess_state (flux_subprocess_t *p);
*/
const char *flux_subprocess_state_string (flux_subprocess_state_t state);

/* Return true if subprocess p is still active, i.e. it is waiting to
* start, still running, or waiting for eof on all streams.
*/
bool flux_subprocess_active (flux_subprocess_t *p);

int flux_subprocess_rank (flux_subprocess_t *p);

/* Returns the errno causing the FLUX_SUBPROCESS_FAILED state to be reached.
Expand Down

0 comments on commit 5736952

Please sign in to comment.