You cannot run netmon and redirect stdout/stderr. This is a desired feature for long running monitoring and if you want to run it as a background task and come back to it for example.
This is because netmon calls printf in C which is buffered by default here in common.h
#define __LOG__(format, loglevel, ...) printf("%s %-5s [%s] [%s:%d] " format "\n", getFormattedTime(), loglevel, __func__, __SHORT_FILE__, __LINE__, ## __VA_ARGS__)
....
#define LOGINFO(format, ...) __LOG__(format, "INFO", ## __VA_ARGS__)
Adding setvbuf(stdout, NULL, _IONBF, 0); to line 82 of netmon.c seems to do the trick, but I have no idea if this is correct/idiomatic to do so. I don't write C.. So I am submitting this as an ask/issue since I don't feel comfortable submitting PR.
You cannot run netmon and redirect stdout/stderr. This is a desired feature for long running monitoring and if you want to run it as a background task and come back to it for example.
This is because
netmoncallsprintfin C which is buffered by default here incommon.hAdding
setvbuf(stdout, NULL, _IONBF, 0);to line 82 of netmon.c seems to do the trick, but I have no idea if this is correct/idiomatic to do so. I don't write C.. So I am submitting this as an ask/issue since I don't feel comfortable submitting PR.