On many Linux variants, a systemd
subsystem controls startup and execution of daemons (aka Windows Services analogy).
If one wants to subscribe to events that happen with systemd
units, one option would be to run a tool called journalctl
with --follow
switch. In that case the output of the journalctl
execution will not be immediate, but will be a constant stream of text data that will contain information of interest.
How, using a .NET 5/C# one could invoke journalctl (probably via System.Diagnostics.Process
) in a manner that the continuous stream output can be “monitored” by the application code as it arrives?
journalctl
case is just an easily testable example of such “piping” source in Linux and is not directly related to the approach-of-interested.