I have the following code:
if (!strcmp(ent_child->d_name, "eeprom")){
printf("\tread_from_driver: found a match! ");//DEBUG
get_child_path(child_path, child_path, "eeprom");
printf("The path is: %s\n", child_path);//DEBUG
read_eeprom(child_path);
}
This causes a segfault at some point, (probably get_child_path), but the first printf never happens, even though when I fix the code to be this:
if (!strcmp(ent_child->d_name, "eeprom")){
while(1)
printf("\tread_from_driver: found a match! ");//DEBUG
get_child_path(child_path, child_path, "eeprom");
printf("The path is: %s\n", child_path);//DEBUG
read_eeprom(child_path);
}
It does happen. What’s going on? This is definitely not the first time I observed this behavior.
stdoutis line-buffered by default, which means that you only get updated output when you send a newline character, or when you explicitly callfflush(stdout).