sleep working

unistd.h declares the prototype of the sleep function. where is the sleep function actually defined? where is the control transfered when we include a sleep call in it??

sleep(<timeinsec>):

  1. sets up a signal handler for SIGALRM
  2. relinqishes the cpu - goes into a "wait" state

Is that what you mean? "Control" is transferred to any other running process
But I'm not sure what "control" means in your question.... it is not control of your tty.

From the horses mouth....

sleep