Back to index

glibc  2.9
Functions
setitimer.c File Reference
#include <stddef.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <signal.h>

Go to the source code of this file.

Functions

int __libc_nanosleep (const struct timespec *requested_time, struct timespec *remaining)
int __setitimer (enum __itimer_which which, const struct itimerval *new, struct itimerval *old)

Function Documentation

int __libc_nanosleep ( const struct timespec requested_time,
struct timespec remaining 
)

Definition at line 33 of file nanosleep.c.

{
  assert (sizeof (struct timestruc_t) == sizeof (*req));
  return _nsleep ((struct timestruc_t *) req, (struct timestruc_t *) rem);
}
int __setitimer ( enum __itimer_which  which,
const struct itimerval new,
struct itimerval old 
)

Definition at line 28 of file setitimer.c.

{
  if (new == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  switch (which)
   {
    default:
      __set_errno (EINVAL);
      return -1;

    case ITIMER_VIRTUAL:
    case ITIMER_PROF:
      __set_errno (ENOSYS);
      return -1;

    case ITIMER_REAL:
      break;
   }

  switch (__fork())
   {
    case -1: exit(-1);
    case  0:
       {
        struct timespec ts ={.tv_sec = (long int)new->it_value.tv_sec, .tv_nsec = 0};
        __libc_nanosleep(&ts,&ts);
       __kill(getppid(), SIGALRM);
       exit(0);
       }
    default:
   }
  return 0;
}

Here is the call graph for this function: