Merge latest DTrace changes from Perforce.
Update libproc API to reflect new changes. Approved by: jb
This commit is contained in:
parent
56b3556343
commit
820e067933
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=184697
@ -33,6 +33,8 @@
|
||||
|
||||
struct proc_handle;
|
||||
|
||||
typedef void (*proc_child_func)(void *);
|
||||
|
||||
/* Values returned by proc_state(). */
|
||||
#define PS_IDLE 1
|
||||
#define PS_STOP 2
|
||||
@ -55,7 +57,8 @@ int proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *);
|
||||
int proc_attach(pid_t pid, int flags, struct proc_handle **pphdl);
|
||||
int proc_continue(struct proc_handle *);
|
||||
int proc_clearflags(struct proc_handle *, int);
|
||||
int proc_create(const char *, char * const *, struct proc_handle **);
|
||||
int proc_create(const char *, char * const *, proc_child_func *, void *,
|
||||
struct proc_handle **);
|
||||
int proc_detach(struct proc_handle *);
|
||||
int proc_getflags(struct proc_handle *);
|
||||
int proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *);
|
||||
|
@ -90,7 +90,8 @@ proc_attach(pid_t pid, int flags, struct proc_handle **pphdl)
|
||||
}
|
||||
|
||||
int
|
||||
proc_create(const char *file, char * const *argv, struct proc_handle **pphdl)
|
||||
proc_create(const char *file, char * const *argv, proc_child_func *pcf,
|
||||
void *child_arg, struct proc_handle **pphdl)
|
||||
{
|
||||
struct proc_handle *phdl;
|
||||
struct kevent kev;
|
||||
@ -106,13 +107,16 @@ proc_create(const char *file, char * const *argv, struct proc_handle **pphdl)
|
||||
return (ENOMEM);
|
||||
|
||||
/* Fork a new process. */
|
||||
if ((pid = fork()) == -1)
|
||||
if ((pid = vfork()) == -1)
|
||||
error = errno;
|
||||
else if (pid == 0) {
|
||||
/* The child expects to be traced. */
|
||||
if (ptrace(PT_TRACE_ME, 0, 0, 0) != 0)
|
||||
_exit(1);
|
||||
|
||||
if (pcf != NULL)
|
||||
(*pcf)(child_arg);
|
||||
|
||||
/* Execute the specified file: */
|
||||
execvp(file, argv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user