fn signal_thread_groups<F>(
    task: &Task,
    unchecked_signal: &UncheckedSignal,
    thread_groups: F,
) -> Result<(), Errno>
where
    F: Iterator<Item = Arc<ThreadGroup>>,
{
    let mut last_error = errno!(ESRCH);
    let mut sent_signal = false;

    // This loop keeps track of whether a signal was sent, so that "on
    // success (at least one signal was sent), zero is returned."
    for thread_group in thread_groups {
        let leader = task.get_task(thread_group.leader).ok_or(errno!(ESRCH))?;
        if !task.can_signal(&leader, &unchecked_signal) {
            last_error = errno!(EPERM);
        }

        match send_unchecked_signal(&leader, unchecked_signal) {
            Ok(_) => sent_signal = true,
            Err(errno) => last_error = errno,
        }
    }

    if sent_signal {
        return Ok(());
    } else {
        return Err(last_error);
    }
}
/// Sends a signal to all thread groups in `thread_groups`.
///
/// # Parameters
/// - `task`: The task that is sending the signal.
/// - `unchecked_signal`: The signal that is to be sent. Unchecked, since `0` is a sentinel value
/// where rights are to be checked but no signal is actually sent.
/// - `thread_groups`: The thread groups to signal.
///
/// # Returns
/// Returns Ok(()) if at least one signal was sent, otherwise the last error that was encountered.
Sends a signal to all thread groups in `thread_groups`.
Sends a signal to all thread groups in ` thread_groups ` .
fn signal_thread_groups<F>(
    task: &Task,
    unchecked_signal: &UncheckedSignal,
    thread_groups: F,
) -> Result<(), Errno>
where
    F: Iterator<Item = Arc<ThreadGroup>>,
{
    let mut last_error = errno!(ESRCH);
    let mut sent_signal = false;
    // This loop keeps track of whether a signal was sent, so that "on
    // success (at least one signal was sent), zero is returned."
    for thread_group in thread_groups {
        let leader = task.get_task(thread_group.leader).ok_or(errno!(ESRCH))?;
        if !task.can_signal(&leader, &unchecked_signal) {
            last_error = errno!(EPERM);
        }
        match send_unchecked_signal(&leader, unchecked_signal) {
            Ok(_) => sent_signal = true,
            Err(errno) => last_error = errno,
        }
    }
    if sent_signal {
        return Ok(());
    } else {
        return Err(last_error);
    }
}
fn signal_thread_groups < F > ( task : & Task , unchecked_signal : & UncheckedSignal , thread_groups : F , ) -> Result < ( ) , Errno > where F : Iterator < Item = Arc < ThreadGroup > > , { let mut last_error = errno ! ( ESRCH ) ; let mut sent_signal = false ; // This loop keeps track of whether a signal was sent, so that "on // success (at least one signal was sent), zero is returned." for thread_group in thread_groups { let leader = task . get_task ( thread_group . leader ) . ok_or ( errno ! ( ESRCH ) ) ? ; if ! task . can_signal ( & leader , & unchecked_signal ) { last_error = errno ! ( EPERM ) ; } match send_unchecked_signal ( & leader , unchecked_signal ) { Ok ( _ ) => sent_signal = true , Err ( errno ) => last_error = errno , } } if sent_signal { return Ok ( ( ) ) ; } else { return Err ( last_error ) ; } }
Sends a signal to all thread groups in `thread_groups`.
Sends a signal to all thread groups in ` thread_groups ` .
task
&Task
unchecked_signal
&UncheckedSignal
thread_groups
F
Returns Ok(()) if at least one signal was sent, otherwise the last error that was encountered.
Returns Ok (( )) if at least one signal was sent otherwise the last error that was encountered .
task
&Task
The task that is sending the signal.
The task that is sending the signal .
unchecked_signal
&UncheckedSignal
The signal that is to be sent. Unchecked, since `0` is a sentinel value
where rights are to be checked but no signal is actually sent.
The signal that is to be sent . Unchecked since ` 0 ` is a sentinel value where rights are to be checked but no signal is actually sent .
thread_groups
F
The thread groups to signal.
The thread groups to signal .