Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Can periodic hook stop rescheduling?



[>workers]

On Sep 13,  2:20pm, Peter Stephenson wrote:
} Subject: Re: Can periodic hook stop rescheduling?
}
} On Tue, 13 Sep 2016 10:49:35 +0200
} Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
} > I'm using sched to call a function. The problem is, it sometimes
} > doesn't reschedule.
} 
} The function that's being called is certainly not immune from getting
} ^C, and that can certainly stop "sched +2" in its tracks just like any
} other command.  The only general fix for this would be blocking SIGINT
} sufficiently early that ^C doesn't hit this and restoring it later ---
} but given sched +2 is the first line of the script anyway that doesn't
} look promising.

I suspect that what's happening is that the interrupt arrives during
the user input loop such that errflag is already set before the sched
function even begins running; and it therefore stops immediately on
entry without executing any actual commands.

Unfortunately it's a race condition so it's difficult to test/prove
this hypothesis.  However, there's pretty minimal testing of errflag
in preprompt() and none at all in cacl_timeout() so it might suffice
to check errflag and if set then defer the sched processing until the
next opportunity.  There would still be a race possible, but the window
would be much smaller.

The other (not mutually exclusive) option would be to make recurring
schedules part of the "sched" builtin itself, so that if a recurrent
event were interrupted it would nevertheless be rescheduled for the
next interval.

Neither of these is going to help Sebastian with 5.2-and-earlier.



Messages sorted by: Reverse Date, Date, Thread, Author