4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #include <sys/types.h>
34 * The process context library allows callers to use the facilities
35 * of /proc to control processes in a simplified way by managing
36 * the process via an event loop. The controlling process expresses
37 * interest in various events which are handled as callbacks by the
45 typedef struct __pctx pctx_t
;
48 * A vprintf-like error handling routine can be passed in for use
49 * by more sophisticated callers. If specified as NULL, errors
50 * are written to stderr.
52 typedef void (pctx_errfn_t
)(const char *fn
, const char *fmt
, va_list ap
);
54 extern pctx_t
*pctx_create(const char *filename
, char *const *argv
,
55 void *arg
, int verbose
, pctx_errfn_t
*errfn
);
56 extern pctx_t
*pctx_capture(pid_t pid
,
57 void *arg
, int verbose
, pctx_errfn_t
*errfn
);
59 typedef int pctx_sysc_execfn_t(pctx_t
*, pid_t
, id_t
, char *, void *);
60 typedef void pctx_sysc_forkfn_t(pctx_t
*, pid_t
, id_t
, pid_t
, void *);
61 typedef void pctx_sysc_exitfn_t(pctx_t
*, pid_t
, id_t
, int, void *);
62 typedef int pctx_sysc_lwp_createfn_t(pctx_t
*, pid_t
, id_t
, void *);
63 typedef int pctx_init_lwpfn_t(pctx_t
*, pid_t
, id_t
, void *);
64 typedef int pctx_fini_lwpfn_t(pctx_t
*, pid_t
, id_t
, void *);
65 typedef int pctx_sysc_lwp_exitfn_t(pctx_t
*, pid_t
, id_t
, void *);
67 extern void pctx_terminate(pctx_t
*);
74 PCTX_SYSC_LWP_CREATE_EVENT
,
77 PCTX_SYSC_LWP_EXIT_EVENT
80 extern int pctx_set_events(pctx_t
*pctx
, ...);
82 extern int pctx_run(pctx_t
*pctx
, uint_t msec
, uint_t nsamples
,
83 int (*tick
)(pctx_t
*, pid_t
, id_t
, void *));
85 extern void pctx_release(pctx_t
*pctx
);
88 * Implementation-private interfaces used by libcpc.
91 extern int __pctx_cpc(pctx_t
*, struct __cpc
*, int, id_t
,
92 void *, void *, void *, int);
93 extern void __pctx_cpc_register_callback(void (*)(struct __cpc
*,
100 #endif /* _LIBPCTX_H */