Skip to content

Commit 4dc18e7

Browse files
committed
Scheduling: OR in SCHED_RESET_ON_FORK instead of ANDing it
Scheduling_setPolicy() set the reset-on-fork flag with `policy &= SCHED_RESET_ON_FORK`. SCHED_RESET_ON_FORK is 0x40000000 and the scheduling policies (SCHED_OTHER=0, FIFO=1, RR=2, BATCH=3, IDLE=5) share no bits with it, so `&=` always zeroes the policy to SCHED_OTHER and drops the flag. Enabling "Reset on fork" while choosing a real-time policy therefore either fails with EINVAL (the RT priority no longer matches SCHED_OTHER) or silently downgrades the process to SCHED_OTHER. Use `|=` so the flag is combined with the chosen policy, matching the sibling Scheduling_formatPolicy() which strips it with `policy & ~SCHED_RESET_ON_FORK`. Assisted-by: Claude (Anthropic) Signed-off-by: winklemad <[email protected]>
1 parent a97ad96 commit 4dc18e7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎Scheduling.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static bool Scheduling_setPolicy(Process* p, Arg arg) {
111111

112112
#ifdef SCHED_RESET_ON_FORK
113113
if (reset_on_fork)
114-
policy &= SCHED_RESET_ON_FORK;
114+
policy |= SCHED_RESET_ON_FORK;
115115
#endif
116116

117117
int r = sched_setscheduler(Process_getPid(p), policy, &param);

0 commit comments

Comments
 (0)