svn commit: r184697 - head/lib/libproc
Craig Rodrigues
rodrigc at FreeBSD.org
Wed Nov 5 11:35:44 PST 2008
Author: rodrigc
Date: Wed Nov 5 19:35:43 2008
New Revision: 184697
URL: http://svn.freebsd.org/changeset/base/184697
Log:
Merge latest DTrace changes from Perforce.
Update libproc API to reflect new changes.
Approved by: jb
Modified:
head/lib/libproc/libproc.h
head/lib/libproc/proc_create.c
Modified: head/lib/libproc/libproc.h
==============================================================================
--- head/lib/libproc/libproc.h Wed Nov 5 19:35:09 2008 (r184696)
+++ head/lib/libproc/libproc.h Wed Nov 5 19:35:43 2008 (r184697)
@@ -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 *,
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 *);
Modified: head/lib/libproc/proc_create.c
==============================================================================
--- head/lib/libproc/proc_create.c Wed Nov 5 19:35:09 2008 (r184696)
+++ head/lib/libproc/proc_create.c Wed Nov 5 19:35:43 2008 (r184697)
@@ -90,7 +90,8 @@ proc_attach(pid_t pid, int flags, struct
}
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 * con
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);
More information about the svn-src-all
mailing list