I want to run a system function within a program written in C. This system function is blocking and can take some time before it returns to stdout. The function to be called is snort, and normally is executed on a raspberry pi as followed:
sudo snort -q -A console -i eth0 -c /etc/snort/snort.conf
In the case snort triggers an alert, the parent program should read that line and turn on a LED. I currently am turning on leds as followed:
void triggerLed(void) {
pinMode(7], OUTPUT);
digitalWrite(7, HIGH);
}
int main(void) {
//Execute this function call: sudo snort -q -A console -i eth0 -c /etc/snort/snort.conf
//while executing
//On new line from readline()
//if strcmp(line,"alert")
triggerLed();
//endif
//end while
}
How would you solve this? I tried monitoring syslog, snort however does not write to syslog as I cannot find any alerts.
fyi: Last week I asked this question on: Execute script on Snort alert . Unfortunately, due to a combination a vaguely formed question and a change of scope I rephrased the question here.