From owner-svn-src-head@freebsd.org Sun Dec 3 16:50:17 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC84CDFFC93; Sun, 3 Dec 2017 16:50:17 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 960617E0FD; Sun, 3 Dec 2017 16:50:17 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB3GoGR2056430; Sun, 3 Dec 2017 16:50:16 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB3GoGDV056424; Sun, 3 Dec 2017 16:50:16 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201712031650.vB3GoGDV056424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 3 Dec 2017 16:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326498 - in head: . cddl/contrib/opensolaris/lib/libdtrace/common lib/libproc lib/libproc/tests X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: . cddl/contrib/opensolaris/lib/libdtrace/common lib/libproc lib/libproc/tests X-SVN-Commit-Revision: 326498 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Dec 2017 16:50:17 -0000 Author: markj Date: Sun Dec 3 16:50:16 2017 New Revision: 326498 URL: https://svnweb.freebsd.org/changeset/base/326498 Log: Add an envp argument to proc_create(). This is needed to support dtrace's -x setenv option. MFC after: 2 weeks Modified: head/ObsoleteFiles.inc head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c head/lib/libproc/Makefile head/lib/libproc/libproc.h head/lib/libproc/proc_create.c head/lib/libproc/tests/proc_test.c Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sun Dec 3 13:52:35 2017 (r326497) +++ head/ObsoleteFiles.inc Sun Dec 3 16:50:16 2017 (r326498) @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20171203: libproc version bump +OLD_LIBS+=usr/lib/libproc.so.4 +OLD_LIBS+=usr/lib32/libproc.so.4 # 20171203: new clang import which bumps version from 5.0.0 to 5.0.1. OLD_FILES+=usr/lib/clang/5.0.0/include/sanitizer/allocator_interface.h OLD_FILES+=usr/lib/clang/5.0.0/include/sanitizer/asan_interface.h Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c Sun Dec 3 13:52:35 2017 (r326497) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c Sun Dec 3 16:50:16 2017 (r326498) @@ -967,7 +967,7 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, ch #ifdef illumos if ((dpr->dpr_proc = Pcreate(file, argv, &err, NULL, 0)) == NULL) { #else - if ((err = proc_create(file, argv, pcf, child_arg, + if ((err = proc_create(file, argv, NULL, pcf, child_arg, &dpr->dpr_proc)) != 0) { #endif return (dt_proc_error(dtp, dpr, Modified: head/lib/libproc/Makefile ============================================================================== --- head/lib/libproc/Makefile Sun Dec 3 13:52:35 2017 (r326497) +++ head/lib/libproc/Makefile Sun Dec 3 16:50:16 2017 (r326498) @@ -37,7 +37,7 @@ CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libc CFLAGS+= -DNO_CTF .endif -SHLIB_MAJOR= 4 +SHLIB_MAJOR= 5 MAN= Modified: head/lib/libproc/libproc.h ============================================================================== --- head/lib/libproc/libproc.h Sun Dec 3 13:52:35 2017 (r326497) +++ head/lib/libproc/libproc.h Sun Dec 3 16:50:16 2017 (r326498) @@ -142,8 +142,8 @@ int proc_addr2sym(struct proc_handle *, uintptr_t, cha 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 *, proc_child_func *, void *, - struct proc_handle **); +int proc_create(const char *, char * const *, char * const *, + proc_child_func *, void *, struct proc_handle **); int proc_detach(struct proc_handle *, int); int proc_getflags(struct proc_handle *); int proc_name2sym(struct proc_handle *, const char *, const char *, Modified: head/lib/libproc/proc_create.c ============================================================================== --- head/lib/libproc/proc_create.c Sun Dec 3 13:52:35 2017 (r326497) +++ head/lib/libproc/proc_create.c Sun Dec 3 16:50:16 2017 (r326498) @@ -176,9 +176,10 @@ out: } int -proc_create(const char *file, char * const *argv, proc_child_func *pcf, - void *child_arg, struct proc_handle **pphdl) +proc_create(const char *file, char * const *argv, char * const *envp, + proc_child_func *pcf, void *child_arg, struct proc_handle **pphdl) { + extern char * const *environ; struct proc_handle *phdl; int error, status; pid_t pid; @@ -189,8 +190,7 @@ proc_create(const char *file, char * const *argv, proc error = 0; phdl = NULL; - /* Fork a new process. */ - if ((pid = vfork()) == -1) + if ((pid = fork()) == -1) error = errno; else if (pid == 0) { /* The child expects to be traced. */ @@ -200,18 +200,14 @@ proc_create(const char *file, char * const *argv, proc if (pcf != NULL) (*pcf)(child_arg); - /* Execute the specified file: */ + if (envp != NULL) + environ = envp; + execvp(file, argv); - /* Couldn't execute the file. */ _exit(2); /* NOTREACHED */ } else { - /* The parent owns the process handle. */ - error = proc_init(pid, 0, PS_IDLE, &phdl); - if (error != 0) - goto bad; - /* Wait for the child process to stop. */ if (waitpid(pid, &status, WUNTRACED) == -1) { error = errno; @@ -221,11 +217,15 @@ proc_create(const char *file, char * const *argv, proc /* Check for an unexpected status. */ if (!WIFSTOPPED(status)) { - error = EBUSY; + error = ENOENT; DPRINTFX("ERROR: child process %d status 0x%x", pid, status); goto bad; } - phdl->status = PS_STOP; + + /* The parent owns the process handle. */ + error = proc_init(pid, 0, PS_IDLE, &phdl); + if (error == 0) + phdl->status = PS_STOP; bad: if (error != 0 && phdl != NULL) { Modified: head/lib/libproc/tests/proc_test.c ============================================================================== --- head/lib/libproc/tests/proc_test.c Sun Dec 3 13:52:35 2017 (r326497) +++ head/lib/libproc/tests/proc_test.c Sun Dec 3 16:50:16 2017 (r326498) @@ -65,7 +65,7 @@ start_prog(const struct atf_tc *tc, bool sig) argv[1] = NULL; } - error = proc_create(argv[0], argv, NULL, NULL, &phdl); + error = proc_create(argv[0], argv, NULL, NULL, NULL, &phdl); ATF_REQUIRE_EQ_MSG(error, 0, "failed to run '%s'", target_prog_file); ATF_REQUIRE(phdl != NULL);