[FEATURE] Add mechanism to notify plugins when command passed to runStream has exited
Submission checklist
- [x] I have searched existing issues and confirmed this has not been requested before.
- [x] I have checked existing pull requests for similar changes.
Feature type
Developer / API improvement
Feature summary
Notify the caller of runStream when the command passed to runStream has exited.
Motivation / use case
The runStream command currently does not notify plugins when the command it's executing fails: https://docs.noctalia.dev/noctalia/plugins/development/runtime-api/?section=subprocesses-and-environment#subprocesses-and-environment. It returns a boolean, but that just indicates whether the task was accepted.
This means that it can be difficult to know if the stream has failed. For a plugin that I've worked on, that means that I basically have no way to:
- Know if my service has failed
- Recover a failed service
Proposed solution
This depends on what others need as well of course, but I'd appreciate runStream accepting a callback like onFailure, or something of that nature. This callback could then be called if noctalia notices that the stream has exited. That would allow me to recover the service.
Ideally this callback would receive useful data like error status codes, etc.
Alternatives considered
Checking the streams for indications that it has failed. But for the plugin I was working on this was not possible, as it's perfectly valid for the stream to never return anything, since the output depends entirely on what the user is doing.
References / related projects
No response
Additional context
One other thing that comes to mind, which is slightly related, is that it might also be nice to return a PID of the process executed by runStream, instead of a boolean. The PID still meaning that the work was accepted and executed, but instead conveying more information than just the bool.