Skip to content

Commit

Permalink
Fix a bug in query_process_id_list where the first procid in the li…
Browse files Browse the repository at this point in the history
…st was missing
  • Loading branch information
ohadravid committed Jan 25, 2024
1 parent ead2593 commit 49577c9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ impl Job {
return Err(JobError::GetInfoFailed(io::Error::last_os_error()));
}

let list = &proc_id_list.list[..proc_id_list.header.NumberOfProcessIdsInList as usize];
let list = proc_id_list
.header
.ProcessIdList
.into_iter()
.chain(proc_id_list.list)
.take(proc_id_list.header.NumberOfProcessIdsInList as usize)
.collect();

Ok(list.to_vec())
Ok(list)
}
}

Expand All @@ -60,7 +66,11 @@ mod tests {

let pids = job.query_process_id_list().unwrap();

let current_process_id = std::process::id() as usize;

// It's not equal to 1 because sometime we "catch" `rusty_fork_test` sub procs.
assert!(pids.len() >= 1);

assert!(pids.contains(&current_process_id));
}
}

0 comments on commit 49577c9

Please sign in to comment.