Doubt with signals and sleep function

Hi , I have a doubt with signals and sleep function.

In a program i have this

while(1)
{
   //do some work
   sleep(1);
}

And in a thread i have something like this

    union sigval data;
    char message[1024];
    char msg[1024];
    data.sival_int=0;

    while(1)
    {
        message[0]='\0';
        //Do some work and wait for some events
        strcpy(msg,message);
        datos.sival_ptr=msg;
        sigqueue(getpid(),SIGUSR1,data);
    }

But for some reason , when i send the signal sometimes sleep(1) not execute!
Anybody knows why this happen? Or this shouldn' t happen?

Thanks and bye!

Check the return value on sleep() to see what it thinks its doing.

Also post your signal setup and signal handling code.

Corona688 thank you ! i only need read the man of sleep...

Sleep when is interrupted , stop it and return the number of seconds that are missing.... so i put a while until sleep finish and ....it works! (or i believe that works).

That may work, yes. And errno may tell you more about why it's returning early.