I wrote the following piece of code to simulate a callback. But this got stuck and not even prints "inside main". I tried this on my unix machine and also on online compiler but same behavior. Have I missed anything ?
#include <stdio.h>
#include <unistd.h>
void sleep_50sec()
{
printf("inside sleep_50sec");
sleep(50);
}
int main()
{
int i;
printf("inside main");
sleep(1);
for( i =0; i < 100;i++)
{ printf("Loop %d",i);
sleep_50sec();
}
return 0;
}
Output
root@xyz> ./a.out