From man page of pause
pause() causes the calling process (or thread) to sleep until a signal is delivered that either terminates the process or causes the invocation of a signal-catching function.
From man page of sleep
sleep() makes the calling thread sleep until seconds seconds have elapsed or a signal arrives which is not ignored.
/* This will wait till the signal arrives and it should be handled */
pause();
/* is it same as the above one */
/* This will also sleep for infinite time untill the signal arrives and it should be handled */
while (1) {
int ret = sleep(3);
if (ret != 0)
break;
}
Source code of sleep and pause, both has been implemented in different way.
What is the difference between their implementation?
From application point of view when to use pause and when to use sleep.