GETITIMER(3)               POSIX Programmer's Manual              GETITIMER(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       getitimer, setitimer -- get and set value of interval timer

SSYYNNOOPPSSIISS
       #include <sys/time.h>

       int getitimer(int _w_h_i_c_h, struct itimerval *_v_a_l_u_e);
       int setitimer(int _w_h_i_c_h, const struct itimerval *restrict _v_a_l_u_e,
           struct itimerval *restrict _o_v_a_l_u_e);

DDEESSCCRRIIPPTTIIOONN
       The _g_e_t_i_t_i_m_e_r() function shall store the current value of the timer
       specified by _w_h_i_c_h into the structure pointed to by _v_a_l_u_e.  The
       _s_e_t_i_t_i_m_e_r() function shall set the timer specified by _w_h_i_c_h to the
       value specified in the structure pointed to by _v_a_l_u_e, and if _o_v_a_l_u_e is
       not a null pointer, store the previous value of the timer in the
       structure pointed to by _o_v_a_l_u_e.

       A timer value is defined by the iittiimmeerrvvaall structure, specified in
       _<_s_y_s_/_t_i_m_e_._h_>.  If _i_t___v_a_l_u_e is non-zero, it shall indicate the time to
       the next timer expiration.  If _i_t___i_n_t_e_r_v_a_l is non-zero, it shall
       specify a value to be used in reloading _i_t___v_a_l_u_e when the timer
       expires. Setting _i_t___v_a_l_u_e to 0 shall disable a timer, regardless of the
       value of _i_t___i_n_t_e_r_v_a_l.  Setting _i_t___i_n_t_e_r_v_a_l to 0 shall disable a timer
       after its next expiration (assuming _i_t___v_a_l_u_e is non-zero).

       Implementations may place limitations on the granularity of timer
       values. For each interval timer, if the requested timer value requires
       a finer granularity than the implementation supports, the actual timer
       value shall be rounded up to the next supported value.

       An XSI-conforming implementation provides each process with at least
       three interval timers, which are indicated by the _w_h_i_c_h argument:

       ITIMER_PROF   Decrements both in process virtual time and when the
                     system is running on behalf of the process. It is
                     designed to be used by interpreters in statistically
                     profiling the execution of interpreted programs. Each
                     time the ITIMER_PROF timer expires, the SIGPROF signal is
                     delivered.

       ITIMER_REAL   Decrements in real time. A SIGALRM signal is delivered
                     when this timer expires.

       ITIMER_VIRTUAL
                     Decrements in process virtual time. It runs only when the
                     process is executing. A SIGVTALRM signal is delivered
                     when it expires.

       The interaction between _s_e_t_i_t_i_m_e_r() and _a_l_a_r_m() or _s_l_e_e_p() is
       unspecified.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _g_e_t_i_t_i_m_e_r() or _s_e_t_i_t_i_m_e_r() shall return 0;
       otherwise, -1 shall be returned and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _s_e_t_i_t_i_m_e_r() function shall fail if:

       EEIINNVVAALL The _v_a_l_u_e argument is not in canonical form. (In canonical form,
              the number of microseconds is a non-negative integer less than
              1000000 and the number of seconds is a non-negative integer.)

       The _g_e_t_i_t_i_m_e_r() and _s_e_t_i_t_i_m_e_r() functions may fail if:

       EEIINNVVAALL The _w_h_i_c_h argument is not recognized.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Applications should use the _t_i_m_e_r___g_e_t_t_i_m_e() and _t_i_m_e_r___s_e_t_t_i_m_e()
       functions instead of the obsolescent _g_e_t_i_t_i_m_e_r() and _s_e_t_i_t_i_m_e_r()
       functions, respectively.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       The _g_e_t_i_t_i_m_e_r() and _s_e_t_i_t_i_m_e_r() functions may be removed in a future
       version.

SSEEEE AALLSSOO
       _a_l_a_r_m(), _e_x_e_c, _s_l_e_e_p(), _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n()

       The Base Definitions volume of POSIX.1-2008, <<ssiiggnnaall..hh>>, <<ssyyss__ttiimmee..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                         GETITIMER(3)
