JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Extended Library Functions     Oracle Solaris 10 8/11 Information Library
search filter icon
search icon

Document Information

Preface

Extended Library Functions - Part 1

Extended Library Functions - Part 2

Extended Library Functions - Part 3

Extended Library Functions - Part 4

Extended Library Functions - Part 5

Extended Library Functions - Part 6

sin(3M)

sincos(3M)

sincosf(3M)

sincosl(3M)

sinf(3M)

sinh(3M)

sinhf(3M)

sinhl(3M)

sinl(3M)

smf_degrade_instance(3SCF)

smf_disable_instance(3SCF)

smf_enable_instance(3SCF)

smf_get_state(3SCF)

smf_maintain_instance(3SCF)

smf_refresh_instance(3SCF)

smf_restart_instance(3SCF)

smf_restore_instance(3SCF)

sqrt(3M)

sqrtf(3M)

sqrtl(3M)

SSAAgentIsAlive(3SNMP)

SSAGetTrapPort(3SNMP)

SSAOidCmp(3SNMP)

SSAOidCpy(3SNMP)

SSAOidDup(3SNMP)

SSAOidFree(3SNMP)

SSAOidInit(3SNMP)

SSAOidNew(3SNMP)

SSAOidString(3SNMP)

SSAOidStrToOid(3SNMP)

SSAOidZero(3SNMP)

SSARegSubagent(3SNMP)

SSARegSubtable(3SNMP)

SSARegSubtree(3SNMP)

SSASendTrap(3SNMP)

SSAStringCpy(3SNMP)

SSAStringInit(3SNMP)

SSAStringToChar(3SNMP)

SSAStringZero(3SNMP)

SSASubagentOpen(3SNMP)

stdarg(3EXT)

step(3GEN)

stobclear(3TSOL)

stobl(3TSOL)

stobsl(3TSOL)

strcadd(3GEN)

strccpy(3GEN)

streadd(3GEN)

strecpy(3GEN)

strfind(3GEN)

strrspn(3GEN)

str_to_label(3TSOL)

strtrns(3GEN)

Sun_MP_SendScsiCmd(3MPAPI)

SUNW_C_GetMechSession(3EXT)

SUNW_C_KeyToObject(3EXT)

sysevent_bind_handle(3SYSEVENT)

sysevent_free(3SYSEVENT)

sysevent_get_attr_list(3SYSEVENT)

sysevent_get_class_name(3SYSEVENT)

sysevent_get_pid(3SYSEVENT)

sysevent_get_pub_name(3SYSEVENT)

sysevent_get_seq(3SYSEVENT)

sysevent_get_size(3SYSEVENT)

sysevent_get_subclass_name(3SYSEVENT)

sysevent_get_time(3SYSEVENT)

sysevent_get_vendor_name(3SYSEVENT)

sysevent_post_event(3SYSEVENT)

sysevent_subscribe_event(3SYSEVENT)

sysevent_unbind_handle(3SYSEVENT)

sysevent_unsubscribe_event(3SYSEVENT)

tan(3M)

tanf(3M)

tanh(3M)

tanhf(3M)

tanhl(3M)

tanl(3M)

Task(3PERL)

tgamma(3M)

tgammaf(3M)

tgammal(3M)

tnfctl_buffer_alloc(3TNF)

tnfctl_buffer_dealloc(3TNF)

tnfctl_check_libs(3TNF)

tnfctl_close(3TNF)

tnfctl_continue(3TNF)

tnfctl_exec_open(3TNF)

tnfctl_filter_list_add(3TNF)

tnfctl_filter_list_delete(3TNF)

tnfctl_filter_list_get(3TNF)

tnfctl_filter_state_set(3TNF)

tnfctl_indirect_open(3TNF)

tnfctl_internal_open(3TNF)

tnfctl_kernel_open(3TNF)

tnfctl_pid_open(3TNF)

tnfctl_probe_apply(3TNF)

tnfctl_probe_apply_ids(3TNF)

tnfctl_probe_connect(3TNF)

tnfctl_probe_disable(3TNF)

tnfctl_probe_disconnect_all(3TNF)

tnfctl_probe_enable(3TNF)

tnfctl_probe_state_get(3TNF)

tnfctl_probe_trace(3TNF)

tnfctl_probe_untrace(3TNF)

tnfctl_register_funcs(3TNF)

tnfctl_strerror(3TNF)

tnfctl_trace_attrs_get(3TNF)

tnfctl_trace_state_set(3TNF)

TNF_DEBUG(3TNF)

TNF_DECLARE_RECORD(3TNF)

TNF_DEFINE_RECORD_1(3TNF)

TNF_DEFINE_RECORD_2(3TNF)

TNF_DEFINE_RECORD_3(3TNF)

TNF_DEFINE_RECORD_4(3TNF)

TNF_DEFINE_RECORD_5(3TNF)

TNF_PROBE_0(3TNF)

TNF_PROBE_0_DEBUG(3TNF)

TNF_PROBE_1(3TNF)

TNF_PROBE_1_DEBUG(3TNF)

TNF_PROBE_2(3TNF)

TNF_PROBE_2_DEBUG(3TNF)

TNF_PROBE_3(3TNF)

TNF_PROBE_3_DEBUG(3TNF)

TNF_PROBE(3TNF)

TNF_PROBE_4(3TNF)

TNF_PROBE_4_DEBUG(3TNF)

TNF_PROBE_5(3TNF)

TNF_PROBE_5_DEBUG(3TNF)

tnf_process_disable(3TNF)

tnf_process_enable(3TNF)

tnf_thread_disable(3TNF)

tnf_thread_enable(3TNF)

touchlock(3MAIL)

tracing(3TNF)

trunc(3M)

truncf(3M)

truncl(3M)

tsalarm_get(3EXT)

tsalarm_set(3EXT)

tsol_getrhtype(3TSOL)

tsol_lbuild_create(3TSOL)

tsol_lbuild_destroy(3TSOL)

tsol_lbuild_get(3TSOL)

tsol_lbuild_set(3TSOL)

Ucred(3PERL)

uuid_clear(3UUID)

uuid_compare(3UUID)

uuid_copy(3UUID)

uuid_generate(3UUID)

uuid_generate_random(3UUID)

uuid_generate_time(3UUID)

uuid_is_null(3UUID)

uuid_parse(3UUID)

uuid_time(3UUID)

uuid_unparse(3UUID)

v12n(3EXT)

v12n_capabilities(3EXT)

v12n_chassis_serialno(3EXT)

v12n_ctrl_domain(3EXT)

v12n_domain_name(3EXT)

v12n_domain_roles(3EXT)

v12n_domain_uuid(3EXT)

varargs(3EXT)

vatan2_(3MVEC)

vatan2f_(3MVEC)

vatan_(3MVEC)

vatanf_(3MVEC)

vc_abs_(3MVEC)

vc_exp_(3MVEC)

vc_log_(3MVEC)

vcos_(3MVEC)

vcosf_(3MVEC)

vcospi_(3MVEC)

vcospif_(3MVEC)

vc_pow_(3MVEC)

vexp_(3MVEC)

vexpf_(3MVEC)

vhypot_(3MVEC)

vhypotf_(3MVEC)

vlog_(3MVEC)

vlogf_(3MVEC)

volmgt_acquire(3VOLMGT)

volmgt_check(3VOLMGT)

volmgt_feature_enabled(3VOLMGT)

volmgt_inuse(3VOLMGT)

volmgt_ownspath(3VOLMGT)

volmgt_release(3VOLMGT)

volmgt_root(3VOLMGT)

volmgt_running(3VOLMGT)

volmgt_symdev(3VOLMGT)

volmgt_symname(3VOLMGT)

vpow_(3MVEC)

vpowf_(3MVEC)

vrhypot_(3MVEC)

vrhypotf_(3MVEC)

vrsqrt_(3MVEC)

vrsqrtf_(3MVEC)

vsin_(3MVEC)

vsincos_(3MVEC)

vsincosf_(3MVEC)

vsincospi_(3MVEC)

vsincospif_(3MVEC)

vsinf_(3MVEC)

vsinpi_(3MVEC)

vsinpif_(3MVEC)

vsqrt_(3MVEC)

vsqrtf_(3MVEC)

vz_abs_(3MVEC)

vz_exp_(3MVEC)

vz_log_(3MVEC)

vz_pow_(3MVEC)

write_vtoc(3EXT)

wsreg_add_child_component(3WSREG)

wsreg_add_compatible_version(3WSREG)

wsreg_add_dependent_component(3WSREG)

wsreg_add_display_name(3WSREG)

wsreg_add_required_component(3WSREG)

wsreg_can_access_registry(3WSREG)

wsreg_clone_component(3WSREG)

wsreg_components_equal(3WSREG)

wsreg_create_component(3WSREG)

wsreg_free_component(3WSREG)

wsreg_free_component_array(3WSREG)

wsreg_get(3WSREG)

wsreg_get_all(3WSREG)

wsreg_get_child_components(3WSREG)

wsreg_get_compatible_versions(3WSREG)

wsreg_get_data(3WSREG)

wsreg_get_data_pairs(3WSREG)

wsreg_get_dependent_components(3WSREG)

wsreg_get_display_languages(3WSREG)

wsreg_get_display_name(3WSREG)

wsreg_get_id(3WSREG)

wsreg_get_instance(3WSREG)

wsreg_get_location(3WSREG)

wsreg_get_parent(3WSREG)

wsreg_get_required_components(3WSREG)

wsreg_get_type(3WSREG)

wsreg_get_uninstaller(3WSREG)

wsreg_get_unique_name(3WSREG)

wsreg_get_vendor(3WSREG)

wsreg_get_version(3WSREG)

wsreg_initialize(3WSREG)

wsreg_query_create(3WSREG)

wsreg_query_free(3WSREG)

wsreg_query_get_id(3WSREG)

wsreg_query_get_instance(3WSREG)

wsreg_query_get_location(3WSREG)

wsreg_query_get_unique_name(3WSREG)

wsreg_query_get_version(3WSREG)

wsreg_query_set_id(3WSREG)

wsreg_query_set_instance(3WSREG)

wsreg_query_set_location(3WSREG)

wsreg_query_set_unique_name(3WSREG)

wsreg_query_set_version(3WSREG)

wsreg_register(3WSREG)

wsreg_remove_child_component(3WSREG)

wsreg_remove_compatible_version(3WSREG)

wsreg_remove_dependent_component(3WSREG)

wsreg_remove_display_name(3WSREG)

wsreg_remove_required_component(3WSREG)

wsreg_set_data(3WSREG)

wsreg_set_id(3WSREG)

wsreg_set_instance(3WSREG)

wsreg_set_location(3WSREG)

wsreg_set_parent(3WSREG)

wsreg_set_type(3WSREG)

wsreg_set_uninstaller(3WSREG)

wsreg_set_unique_name(3WSREG)

wsreg_set_vendor(3WSREG)

wsreg_set_version(3WSREG)

wsreg_unregister(3WSREG)

Xbcleartos(3TSOL)

Xbsltos(3TSOL)

XTSOLgetClientAttributes(3XTSOL)

XTSOLgetPropAttributes(3XTSOL)

XTSOLgetPropLabel(3XTSOL)

XTSOLgetPropUID(3XTSOL)

XTSOLgetResAttributes(3XTSOL)

XTSOLgetResLabel(3XTSOL)

XTSOLgetResUID(3XTSOL)

XTSOLgetSSHeight(3XTSOL)

XTSOLgetWorkstationOwner(3XTSOL)

XTSOLIsWindowTrusted(3XTSOL)

XTSOLMakeTPWindow(3XTSOL)

XTSOLsetPolyInstInfo(3XTSOL)

XTSOLsetPropLabel(3XTSOL)

XTSOLsetPropUID(3XTSOL)

XTSOLsetResLabel(3XTSOL)

XTSOLsetResUID(3XTSOL)

XTSOLsetSessionHI(3XTSOL)

XTSOLsetSessionLO(3XTSOL)

XTSOLsetSSHeight(3XTSOL)

XTSOLsetWorkstationOwner(3XTSOL)

y0(3M)

y0f(3M)

y0l(3M)

y1(3M)

y1f(3M)

y1l(3M)

yn(3M)

ynf(3M)

ynl(3M)

tnfctl_pid_open

, tnfctl_exec_open

, tnfctl_continue

- interfaces for direct probe and process control for another process

Synopsis

cc [ flag ... ] file ... -ltnfctl [ library ... ]
#include <tnf/tnfctl.h>

tnfctl_errcode_t tnfctl_pid_open(pid_t pid, tnfctl_handle_t **ret_val);
tnfctl_errcode_t tnfctl_exec_open(const char *pgm_name,
     char * const *argv, char * const *envp,
     const char *libnfprobe_path, const char *ld_preload,
     tnfctl_handle_t **ret_val);
tnfctl_errcode_t tnfctl_continue(tnfctl_handle_t *hndl,
     tnfctl_event_t *evt, tnfctl_handle_t **child_hndl);

Description

The tnfctl_pid_open(), tnfctl_exec_open(), and tnfctl_continue() functions create handles to control probes in another process (direct process probe control). Either tnfctl_pid_open() or tnfctl_exec_open() will return a handle in ret_val that can be used for probe control. On return of these calls, the process is stopped. tnfctl_continue() allows the process specified by hndl to continue execution.

The tnfctl_pid_open() function attaches to a running process with process id of pid. The process is stopped on return of this call. The tnfctl_pid_open() function returns an error message if pid is the same as the calling process. See tnfctl_internal_open(3TNF) for information on internal process probe control. A pointer to an opaque handle is returned in ret_val, which can be used to control the process and the probes in the process. The target process must have libtnfprobe.so.1 (defined in <tnf/tnfctl.h> as macro TNFCTL_LIBTNFPROBE) linked in for probe control to work.

The tnfctl_exec_open() function is used to exec(2) a program and obtain a probe control handle. For probe control to work, the process image to be exec'd must load libtnfprobe.so.1. The tnfctl_exec_open() function makes it simple for the library to be loaded at process start up time. The pgm_name argument is the command to exec. If pgm_name is not an absolute path, then the $PATH environment variable is used to find the pgm_name. argv is a null-terminated argument pointer, that is, it is a null-terminated array of pointers to null-terminated strings. These strings constitute the argument list available to the new process image. The argv argument must have at least one member, and it should point to a string that is the same as pgm_name. See execve(2). The libnfprobe_path argument is an optional argument, and if set, it should be the path to the directory that contains libtnfprobe.so.1. There is no need for a trailing "/" in this argument. This argument is useful if libtnfprobe.so.1 is not installed in /usr/lib. ld_preload is a space-separated list of libraries to preload into the target program. This string should follow the syntax guidelines of the LD_PRELOAD environment variable. See ld.so.1(1). The following illustrates how strings are concatenated to form the LD_PRELOAD environment variable in the new process image:

<current value of $LD_PRELOAD> + <space> +
libtnfprobe_path + "/libtnfprobe.so.1" +<space> +
ld_preload

This option is useful for preloading interposition libraries that have probes in them.

envp is an optional argument, and if set, it is used for the environment of the target program. It is a null-terminated array of pointers to null-terminated strings. These strings constitute the environment of the new process image. See execve(2). If envp is set, it overrides ld_preload. In this case, it is the caller's responsibility to ensure that libtnfprobe.so.1 is loaded into the target program. If envp is not set, the new process image inherits the environment of the calling process, except for LD_PRELOAD.

The ret_val argument is the handle that can be used to control the process and the probes within the process. Upon return, the process is stopped before any user code, including .init sections, has been executed.

The tnfctl_continue() function is a blocking call and lets the target process referenced by hndl continue running. It can only be used on handles returned by tnfctl_pid_open() and tnfctl_exec_open() (direct process probe control). It returns when the target stops; the reason that the process stopped is returned in evt. This call is interruptible by signals. If it is interrupted, the process is stopped, and TNFCTL_EVENT_EINTR is returned in evt. The client of this library will have to decide which signal implies a stop to the target and catch that signal. Since a signal interrupts tnfctl_continue(), it will return, and the caller can decide whether or not to call tnfctl_continue() again.

tnfctl_continue() returns with an event of TNFCTL_EVENT_DLOPEN, TNFCTL_EVENT_DLCLOSE, TNFCTL_EVENT_EXEC, TNFCTL_EVENT_FORK, TNFCTL_EVENT_EXIT, or TNFCTL_EVENT_TARGGONE, respectively, when the target program calls dlopen(3C), dlclose(3C), any flavor of exec(2), fork(2) (or fork1(2)), exit(2), or terminates unexpectedly. If the target program called exec(2), the client then needs to call tnfctl_close(3TNF) on the current handle leaving the target resumed, suspended, or killed (second argument to tnfctl_close(3TNF)). No other libtnfctl interface call can be used on the existing handle. If the client wants to control the exec'ed image, it should leave the old handle suspended, and use tnfctl_pid_open() to reattach to the same process. This new handle can then be used to control the exec'ed image. See EXAMPLES below for sample code. If the target process did a fork(2) or fork1(2), and if control of the child process is not needed, then child_hndl should be NULL. If control of the child process is needed, then child_hndl should be set. If it is set, a pointer to a handle that can be used to control the child process is returned in child_hndl. The child process is stopped at the end of the fork() system call. See EXAMPLES for an example of this event.

Return Values

The tnfctl_pid_open(), tnfctl_exec_open(), and tnfctl_continue() functions return TNFCTL_ERR_NONE upon success.

Errors

The following error codes apply to tnfctl_pid_open():

TNFCTL_ERR_BADARG

The pid specified is the same process. Use tnfctl_internal_open(3TNF) instead.

TNFCTL_ERR_ACCES

Permission denied. No privilege to connect to a setuid process.

TNFCTL_ERR_ALLOCFAIL

A memory allocation failure occurred.

TNFCTL_ERR_BUSY

Another client is already using /proc to control this process or internal tracing is being used.

TNFCTL_ERR_NOTDYNAMIC

The process is not a dynamic executable.

TNFCTL_ERR_NOPROCESS

No such target process exists.

TNFCTL_ERR_NOLIBTNFPROBE

libtnfprobe.so.1 is not linked in the target process.

TNFCTL_ERR_INTERNAL

An internal error occurred.

The following error codes apply to tnfctl_exec_open():

TNFCTL_ERR_ACCES

Permission denied.

TNFCTL_ERR_ALLOCFAIL

A memory allocation failure occurred.

TNFCTL_ERR_NOTDYNAMIC

The target is not a dynamic executable.

TNFCTL_ERR_NOLIBTNFPROBE

libtnfprobe.so.1 is not linked in the target process.

TNFCTL_ERR_FILENOTFOUND

The program is not found.

TNFCTL_ERR_INTERNAL

An internal error occurred.

The following error codes apply to tnfctl_continue():

TNFCTL_ERR_BADARG

Bad input argument. hndl is not a direct process probe control handle.

TNFCTL_ERR_INTERNAL

An internal error occurred.

TNFCTL_ERR_NOPROCESS

No such target process exists.

Examples

Example 1 Using tnfctl_pid_open()

These examples do not include any error-handling code. Only the initial example includes the declaration of the variables that are used in all of the examples.

The following example shows how to preload libtnfprobe.so.1 from the normal location and inherit the parent's environment.

const char        *pgm;
char * const      *argv;
tnfctl_handle_t   *hndl, *new_hndl, *child_hndl;
tnfctl_errcode_t  err;
char * const      *envptr;
extern char       **environ;
tnfctl_event_t    evt;
int               pid;

/* assuming argv has been allocated */
argv[0] = pgm;
/* set up rest of argument vector here */
err = tnfctl_exec_open(pgm, argv, NULL, NULL, NULL, &hndl);

This example shows how to preload two user-supplied libraries libc_probe.so.1 and libthread_probe.so.1. They interpose on the corresponding libc.so and libthread.so interfaces and have probes for function entry and exit. libtnfprobe.so.1 is preloaded from the normal location and the parent's environment is inherited.

/* assuming argv has been allocated */
argv[0] = pgm;
/* set up rest of argument vector here */
err = tnfctl_exec_open(pgm, argv, NULL, NULL,
      "libc_probe.so.1 libthread_probe.so.1", &hndl);

This example preloads an interposition library libc_probe.so.1, and specifies a different location from which to preload libtnfprobe.so.1.

/* assuming argv has been allocated */
argv[0] = pgm;
/* set up rest of argument vector here */
err = tnfctl_exec_open(pgm, argv, NULL, "/opt/SUNWXXX/lib",
      "libc_probe.so.1", &hndl);

To set up the environment explicitly for probe control to work, the target process must link libtnfprobe.so.1. If using envp, it is the caller's responsibility to do so.

/* assuming argv has been allocated */
argv[0] = pgm;
/* set up rest of argument vector here */
/* envptr set up to caller's needs */
err = tnfctl_exec_open(pgm, argv, envptr, NULL, NULL, &hndl);

Use this example to resume a process that does an exec(2) without controlling it.

err = tnfctl_continue(hndl, &evt, NULL);
switch (evt) {
case TNFCTL_EVENT_EXEC:
     /* let target process continue without control */
     err = tnfctl_close(hndl, TNFCTL_TARG_RESUME);
     ...
     break;
}

Alternatively, use the next example to control a process that does an exec(2).

/*
 * assume the pid variable has been set by calling
 * tnfctl_trace_attrs_get()
*/
err = tnfctl_continue(hndl, &evt, NULL);
switch (evt) {
case TNFCTL_EVENT_EXEC:
     /* suspend the target process */
     err = tnfctl_close(hndl, TNFCTL_TARG_SUSPEND);
     /* re-open the exec'ed image */
     err = tnfctl_pid_open(pid, &new_hndl);
     /* new_hndl now controls the exec'ed image */
     ...
     break;
}

To let fork'ed children continue without control, use NULL as the last argument to tnfctl_continue( ).

err = tnfctl_continue(hndl, &evt, NULL);

The next example is how to control child processes that fork(2) or fork1(2) create.

err = tnfctl_continue(hndl, &evt, &child_hndl);
switch (evt) {
case TNFCTL_EVENT_FORK:
     /* spawn a new thread or process to control child_hndl */
     ...
     break;
}

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
SUNWtnfc
MT Level
MT-Safe

See Also

ld(1), prex(1), proc(1), exec(2), execve(2), exit(2), fork(2), TNF_PROBE(3TNF), dlclose(3C), dlopen(3C), libtnfctl(3TNF), tnfctl_close(3TNF), tnfctl_internal_open(3TNF), tracing(3TNF) attributes(5)

Linker and Libraries Guide

Notes

After a call to tnfctl_continue() returns, a client should use tnfctl_trace_attrs_get(3TNF) to check the trace_buf_state member of the trace attributes and make sure that there is no internal error in the target.