Hello!
I have managed to confuse myself over whether I should use close_cb or exit_cb to detect when I have received all the data from an external command's stdout.
I want to run "ps -axco command" in a job, gather the results from stdout, and then do something with the results.
My job_start() specifies an out_cb which is called with each line from stdout and accumulates the lines in a list. My question is: what is the recommended way to know when I have all the data?
I have read the docs for exit_cb and close_cb many times but I can't figure it out.
exit_cb sounds right because it is called when the job ends; but apparently callbacks can still be called after exit_cb due to buffering, which seems to rule out exit_cb as a way of knowing when things are finished.
close_cb is called when the channel is closed – but this seems like the wrong level of abstraction; I don't care about the channel. Anyway, on the plus side, once close_cb is called no more data-handling callbacks will be called. But it turns out I can't rely on close_cb because it isn't always called; in fact I am trying to debug a situation where a job from one plugin prevents another plugin's job's close_cb from being called.
I have looked at all the docs and read the job/channel test code, but I'm still not sure what the recommended way is for this kind of job.
Any help would be much appreciated!
Yours,
Andrew Stewart