Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Nov 2008 19:35:43 +0000 (UTC)
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r184697 - head/lib/libproc
Message-ID:  <200811051935.mA5JZh6l035466@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811051935.mA5JZh6l035466>