POSIX_TRACE_CREATE(3)      POSIX Programmer's Manual     POSIX_TRACE_CREATE(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
       posix_trace_create, posix_trace_create_withlog, posix_trace_flush,
       posix_trace_shutdown -- trace stream initialization, flush, and
       shutdown from a process (TTRRAACCIINNGG)

SSYYNNOOPPSSIISS
       #include <sys/types.h>
       #include <trace.h>

       int posix_trace_create(pid_t _p_i_d,
           const trace_attr_t *restrict _a_t_t_r,
           trace_id_t *restrict _t_r_i_d);
       int posix_trace_create_withlog(pid_t _p_i_d,
           const trace_attr_t *restrict _a_t_t_r, int _f_i_l_e___d_e_s_c,
           trace_id_t *restrict _t_r_i_d);
       int posix_trace_flush(trace_id_t _t_r_i_d);
       int posix_trace_shutdown(trace_id_t _t_r_i_d);

DDEESSCCRRIIPPTTIIOONN
       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() function shall create an active trace stream.
       It allocates all the resources needed by the trace stream being created
       for tracing the process specified by _p_i_d in accordance with the _a_t_t_r
       argument. The _a_t_t_r argument represents the initial attributes of the
       trace stream and shall have been initialized by the function
       _p_o_s_i_x___t_r_a_c_e___a_t_t_r___i_n_i_t() prior to the _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() call. If the
       argument _a_t_t_r is NULL, the default attributes shall be used. The _a_t_t_r
       attributes object shall be manipulated through a set of functions
       described in the _p_o_s_i_x___t_r_a_c_e___a_t_t_r family of functions. If the
       attributes of the object pointed to by _a_t_t_r are modified later, the
       attributes of the trace stream shall not be affected. The _c_r_e_a_t_i_o_n_-_t_i_m_e
       attribute of the newly created trace stream shall be set to the value
       of the system clock, if the Timers option is not supported, or to the
       value of the CLOCK_REALTIME clock, if the Timers option is supported.

       The _p_i_d argument represents the target process to be traced. If the
       process executing this function does not have appropriate privileges to
       trace the process identified by _p_i_d, an error shall be returned. If the
       _p_i_d argument is zero, the calling process shall be traced.

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() function shall store the trace stream
       identifier of the new trace stream in the object pointed to by the _t_r_i_d
       argument. This trace stream identifier shall be used in subsequent
       calls to control tracing. The _t_r_i_d argument may only be used by the
       following functions:

       _p_o_s_i_x___t_r_a_c_e___c_l_e_a_r()                      _p_o_s_i_x___t_r_a_c_e___g_e_t_n_e_x_t___e_v_e_n_t()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_i_d___e_q_u_a_l()              _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_i_d___g_e_t___n_a_m_e()           _p_o_s_i_x___t_r_a_c_e___s_t_a_r_t()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_t_y_p_e_l_i_s_t___g_e_t_n_e_x_t___i_d()   _p_o_s_i_x___t_r_a_c_e___s_t_o_p()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_t_y_p_e_l_i_s_t___r_e_w_i_n_d()       _p_o_s_i_x___t_r_a_c_e___t_i_m_e_d_g_e_t_n_e_x_t___e_v_e_n_t()
       _p_o_s_i_x___t_r_a_c_e___g_e_t___a_t_t_r()                   _p_o_s_i_x___t_r_a_c_e___t_r_i_d___e_v_e_n_t_i_d___o_p_e_n()
       _p_o_s_i_x___t_r_a_c_e___g_e_t___s_t_a_t_u_s()                 _p_o_s_i_x___t_r_a_c_e___t_r_y_g_e_t_n_e_x_t___e_v_e_n_t()

       If the Trace Event Filter option is supported, the following additional
       functions may use the _t_r_i_d argument:

       _p_o_s_i_x___t_r_a_c_e___g_e_t___f_i_l_t_e_r()   _p_o_s_i_x___t_r_a_c_e___s_e_t___f_i_l_t_e_r()

       In particular, notice that the operations normally used by a trace
       analyzer process, such as _p_o_s_i_x___t_r_a_c_e___r_e_w_i_n_d() or _p_o_s_i_x___t_r_a_c_e___c_l_o_s_e(),
       cannot be invoked using the trace stream identifier returned by the
       _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() function.

       A trace stream shall be created in a suspended state.  If the Trace
       Event Filter option is supported, its trace event type filter shall be
       empty.

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() function may be called multiple times from the
       same or different processes, with the system-wide limit indicated by
       the runtime invariant value {TRACE_SYS_MAX}, which has the minimum
       value {_POSIX_TRACE_SYS_MAX}.

       The trace stream identifier returned by the _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e()
       function in the argument pointed to by _t_r_i_d is valid only in the
       process that made the function call. If it is used from another
       process, that is a child process, in functions defined in POSIX.1-2008,
       these functions shall return with the error [[EEIINNVVAALL]].

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() function shall be equivalent to
       _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e(), except that it associates a trace log with this
       stream. The _f_i_l_e___d_e_s_c argument shall be the file descriptor designating
       the trace log destination. The function shall fail if this file
       descriptor refers to a file with a file type that is not compatible
       with the log policy associated with the trace log. The list of the
       appropriate file types that are compatible with each log policy is
       implementation-defined.

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() function shall return in the parameter
       pointed to by _t_r_i_d the trace stream identifier, which uniquely
       identifies the newly created trace stream, and shall be used in
       subsequent calls to control tracing. The _t_r_i_d argument may only be used
       by the following functions:

       _p_o_s_i_x___t_r_a_c_e___c_l_e_a_r()                      _p_o_s_i_x___t_r_a_c_e___g_e_t___s_t_a_t_u_s()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_i_d___e_q_u_a_l()              _p_o_s_i_x___t_r_a_c_e___g_e_t_n_e_x_t___e_v_e_n_t()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_i_d___g_e_t___n_a_m_e()           _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_t_y_p_e_l_i_s_t___g_e_t_n_e_x_t___i_d()   _p_o_s_i_x___t_r_a_c_e___s_t_a_r_t()
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_t_y_p_e_l_i_s_t___r_e_w_i_n_d()       _p_o_s_i_x___t_r_a_c_e___s_t_o_p()
       _p_o_s_i_x___t_r_a_c_e___f_l_u_s_h()                      _p_o_s_i_x___t_r_a_c_e___t_i_m_e_d_g_e_t_n_e_x_t___e_v_e_n_t()
       _p_o_s_i_x___t_r_a_c_e___g_e_t___a_t_t_r()                   _p_o_s_i_x___t_r_a_c_e___t_r_i_d___e_v_e_n_t_i_d___o_p_e_n()

       If the Trace Event Filter option is supported, the following additional
       functions may use the _t_r_i_d argument:

       _p_o_s_i_x___t_r_a_c_e___g_e_t___f_i_l_t_e_r()   _p_o_s_i_x___t_r_a_c_e___s_e_t___f_i_l_t_e_r()

       In particular, notice that the operations normally used by a trace
       analyzer process, such as _p_o_s_i_x___t_r_a_c_e___r_e_w_i_n_d() or _p_o_s_i_x___t_r_a_c_e___c_l_o_s_e(),
       cannot be invoked using the trace stream identifier returned by the
       _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() function.

       The _p_o_s_i_x___t_r_a_c_e___f_l_u_s_h() function shall initiate a flush operation which
       copies the contents of the trace stream identified by the argument _t_r_i_d
       into the trace log associated with the trace stream at the creation
       time. If no trace log has been associated with the trace stream pointed
       to by _t_r_i_d, this function shall return an error. The termination of the
       flush operation can be polled by the _p_o_s_i_x___t_r_a_c_e___g_e_t___s_t_a_t_u_s() function.
       During the flush operation, it shall be possible to trace new trace
       events up to the point when the trace stream becomes full.  After
       flushing is completed, the space used by the flushed trace events shall
       be available for tracing new trace events.

       If flushing the trace stream causes the resulting trace log to become
       full, the trace log full policy shall be applied. If the trace _l_o_g_-
       _f_u_l_l_-_p_o_l_i_c_y attribute is set, the following occurs:

       POSIX_TRACE_UNTIL_FULL
             The trace events that have not yet been flushed shall be
             discarded.

       POSIX_TRACE_LOOP
             The trace events that have not yet been flushed shall be written
             to the beginning of the trace log, overwriting previous trace
             events stored there.

       POSIX_TRACE_APPEND
             The trace events that have not yet been flushed shall be appended
             to the trace log.

       The _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function shall stop the tracing of trace
       events in the trace stream identified by _t_r_i_d, as if _p_o_s_i_x___t_r_a_c_e___s_t_o_p()
       had been invoked. The _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function shall free all
       the resources associated with the trace stream.

       The _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function shall not return until all the
       resources associated with the trace stream have been freed. When the
       _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function returns, the _t_r_i_d argument becomes an
       invalid trace stream identifier. A call to this function shall
       unconditionally deallocate the resources regardless of whether all
       trace events have been retrieved by the analyzer process.  Any thread
       blocked on one of the _t_r_a_c_e___g_e_t_n_e_x_t___e_v_e_n_t() functions (which specified
       this _t_r_i_d) before this call is unblocked with the error [[EEIINNVVAALL]].

       If the process exits, invokes a member of the _e_x_e_c family of functions,
       or is terminated, the trace streams that the process had created and
       that have not yet been shut down, shall be automatically shut down as
       if an explicit call were made to the _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function.

       For an active trace stream with log, when the _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n()
       function is called, all trace events that have not yet been flushed to
       the trace log shall be flushed, as in the _p_o_s_i_x___t_r_a_c_e___f_l_u_s_h() function,
       and the trace log shall be closed.

       When a trace log is closed, all the information that may be retrieved
       later from the trace log through the trace interface shall have been
       written to the trace log. This information includes the trace
       attributes, the list of trace event types (with the mapping between
       trace event names and trace event type identifiers), and the trace
       status.

       In addition, unspecified information shall be written to the trace log
       to allow detection of a valid trace log during the _p_o_s_i_x___t_r_a_c_e___o_p_e_n()
       operation.

       The _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() function shall not return until all trace
       events have been flushed.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, these functions shall return a value of
       zero. Otherwise, they shall return the corresponding error number.

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() and _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() functions
       store the trace stream identifier value in the object pointed to by
       _t_r_i_d, if successful.

EERRRROORRSS
       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e() and _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() functions
       shall fail if:

       EEAAGGAAIINN No more trace streams can be started now.  {TRACE_SYS_MAX} has
              been exceeded.

       EEIINNTTRR  The operation was interrupted by a signal. No trace stream was
              created.

       EEIINNVVAALL One or more of the trace parameters specified by the _a_t_t_r
              parameter is invalid.

       EENNOOMMEEMM The implementation does not currently have sufficient memory to
              create the trace stream with the specified parameters.

       EEPPEERRMM  The caller does not have appropriate privileges to trace the
              process specified by _p_i_d.

       EESSRRCCHH  The _p_i_d argument does not refer to an existing process.

       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g() function shall fail if:

       EEBBAADDFF  The _f_i_l_e___d_e_s_c argument is not a valid file descriptor open for
              writing.

       EEIINNVVAALL The _f_i_l_e___d_e_s_c argument refers to a file with a file type that
              does not support the log policy associated with the trace log.

       EENNOOSSPPCC No space left on device. The device corresponding to the
              argument _f_i_l_e___d_e_s_c does not contain the space required to create
              this trace log.

       The _p_o_s_i_x___t_r_a_c_e___f_l_u_s_h() and _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() functions shall fail
       if:

       EEIINNVVAALL The value of the _t_r_i_d argument does not correspond to an active
              trace stream with log.

       EEFFBBIIGG  The trace log file has attempted to exceed an implementation-
              defined maximum file size.

       EENNOOSSPPCC No space left on device.

       _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
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       The _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e(), _p_o_s_i_x___t_r_a_c_e___c_r_e_a_t_e___w_i_t_h_l_o_g(),
       _p_o_s_i_x___t_r_a_c_e___f_l_u_s_h(), and _p_o_s_i_x___t_r_a_c_e___s_h_u_t_d_o_w_n() functions may be
       removed in a future version.

SSEEEE AALLSSOO
       _c_l_o_c_k___g_e_t_r_e_s(), _e_x_e_c, _p_o_s_i_x___t_r_a_c_e___a_t_t_r___d_e_s_t_r_o_y(), _p_o_s_i_x___t_r_a_c_e___c_l_e_a_r(),
       _p_o_s_i_x___t_r_a_c_e___c_l_o_s_e(), _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_i_d___e_q_u_a_l(),
       _p_o_s_i_x___t_r_a_c_e___e_v_e_n_t_t_y_p_e_l_i_s_t___g_e_t_n_e_x_t___i_d(), _p_o_s_i_x___t_r_a_c_e___g_e_t___a_t_t_r(),
       _p_o_s_i_x___t_r_a_c_e___g_e_t___f_i_l_t_e_r(), _p_o_s_i_x___t_r_a_c_e___g_e_t_n_e_x_t___e_v_e_n_t(),
       _p_o_s_i_x___t_r_a_c_e___s_t_a_r_t(), _p_o_s_i_x___t_r_a_c_e___s_t_a_r_t(), _t_i_m_e()

       The Base Definitions volume of POSIX.1-2008, <<ssyyss__ttyyppeess..hh>>, <<ttrraaccee..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                POSIX_TRACE_CREATE(3)
