> How should i make my program go asleep and wake up when OS tells that i have something to read?
You just described select()
You don't need to do anything to make your process go to sleep, or to get it to wake up later on.
while ( (status=select(....)) >= 0 ) {
if ( status == 0 ) {
// timeout
} else {
// one or more file descriptors are ready, do something
}
}