popen and fgets, underflow!
I wonder if you can give me any suggestions on how to deal with this problem.
My application crashesh after a few days of looping.
#0 0xffffe430 in __kernel_vsyscall ()
#1 0xb7d4670b in read () from /lib/libc.so.6
#2 0xb7cefd8c in _IO_file_underflow () from /lib/libc.so.6
#3 0xb7cf175b in _IO_default_uflow () from /lib/libc.so.6
#4 0xb7cf2bc8 in __uflow () from /lib/libc.so.6
#5 0xb7ce57d6 in _IO_getline_info () from /lib/libc.so.6
#6 0xb7ce5721 in _IO_getline () from /lib/libc.so.6
#7 0xb7ce455d in fgets () from /lib/libc.so.6
The fgets() is executed on a stream opened with popen ()
Its is beeing run in 6 threads at the same time with about 50ms in between, but also at the same time.
If I use fread() I get the same results.....
popen string reads " ping 192.168.1.10 -I hso0 -c 2 -w 2" or similar.
//opens bourneshell and executes command
stream = popen(popenstring.c_str(), "r");
if (stream != NULL)
/* //reads data if present at stdout
while (fgets(buffer, sizeof(buffer)-1, stream) != NULL )
//append data if valid
I am pinging through 3 interfaces in two threads for each.
One to see if its alive, the other to gather ping results and calculate an average ping.
The lines read from popen are maximum 380 chars, buffer is at 4096.
This exact routine is beeing run by some other applications, but not in multiple threads, and then there is no problem..
I can not see any error in this popen /fgets handling, as this is how its usually done.
Can any one give me some pointers to possible causes for underflow with fgets and popen?
Many thanks for any suggestion!