pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/cwrappers cwrappers-20161125: If spawn.h and ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ba1fdd5cfa07
branches:  trunk
changeset: 355258:ba1fdd5cfa07
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sun Nov 27 11:46:45 2016 +0000

description:
cwrappers-20161125: If spawn.h and posix_spawnp exist, prefer them over
vfork and execp.

diffstat:

 pkgtools/cwrappers/Makefile                 |     5 +-
 pkgtools/cwrappers/files/bin/base-wrapper.c |     5 +-
 pkgtools/cwrappers/files/bin/common.c       |    54 +-
 pkgtools/cwrappers/files/bin/common.h       |     4 +-
 pkgtools/cwrappers/files/bin/config.h.in    |    55 +
 pkgtools/cwrappers/files/bin/configure      |  4329 +++++++++++++++++++++++++++
 pkgtools/cwrappers/files/bin/configure.ac   |    11 +
 7 files changed, 4439 insertions(+), 24 deletions(-)

diffs (truncated from 4564 to 300 lines):

diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/Makefile
--- a/pkgtools/cwrappers/Makefile       Sun Nov 27 10:56:23 2016 +0000
+++ b/pkgtools/cwrappers/Makefile       Sun Nov 27 11:46:45 2016 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.17 2016/11/25 22:46:40 joerg Exp $
+# $NetBSD: Makefile,v 1.18 2016/11/27 11:46:45 joerg Exp $
 
-PKGNAME=               cwrappers-20160908
+PKGNAME=               cwrappers-20161125
 CATEGORIES=            pkgtools sysutils
 
 MAINTAINER=            joerg%NetBSD.org@localhost
@@ -8,6 +8,7 @@
 COMMENT=               pkgsrc compiler wrappers
 LICENSE=               modified-bsd
 
+GNU_CONFIGURE=         yes
 USE_BSD_MAKEFILE=      yes
 USE_FEATURES=          nbcompat
 
diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/files/bin/base-wrapper.c
--- a/pkgtools/cwrappers/files/bin/base-wrapper.c       Sun Nov 27 10:56:23 2016 +0000
+++ b/pkgtools/cwrappers/files/bin/base-wrapper.c       Sun Nov 27 11:46:45 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: base-wrapper.c,v 1.2 2015/04/19 14:30:07 jperkin Exp $ */
+/* $NetBSD: base-wrapper.c,v 1.3 2016/11/27 11:46:45 joerg Exp $ */
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -102,6 +102,7 @@
 int
 main(int argc, char **argv)
 {
+       extern char **environ;
        int do_fork, rv;
        FILE *fp;
        struct arglist args;
@@ -169,7 +170,7 @@
        do_fork = 0;
 #endif
 
-       rv = command_exec(&args, do_fork);
+       rv = command_exec(&args, do_fork, environ);
 
 #if defined(WRAPPER_LIBTOOL) || defined(WRAPPER_SHLIBTOOL)
        if (rv == 0)
diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/files/bin/common.c
--- a/pkgtools/cwrappers/files/bin/common.c     Sun Nov 27 10:56:23 2016 +0000
+++ b/pkgtools/cwrappers/files/bin/common.c     Sun Nov 27 11:46:45 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.4 2015/04/19 13:30:35 tnn Exp $ */
+/* $NetBSD: common.c,v 1.5 2016/11/27 11:46:45 joerg Exp $ */
 
 /*-
  * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -30,12 +30,16 @@
  */
 
 #include <nbcompat.h>
+#include "config.h"
 #include <sys/wait.h>
 #include <nbcompat/err.h>
 #include <nbcompat/stdio.h>
 #include <nbcompat/stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#if defined(HAVE_POSIX_SPAWNP) && defined(HAVE_SPAWN_H)
+#include <spawn.h>
+#endif
 
 #include "common.h"
 
@@ -310,11 +314,22 @@
                free(buf);
 }
 
+static void
+command_child_exec(char **argv)
+{
+       static const char failed_exec_msg[] = "exec failed\n";
+       int status;
+
+       execvp(exec_name, argv);
+       status = write(STDERR_FILENO, failed_exec_msg,
+           sizeof(failed_exec_msg) - 1);
+       _exit(255 | status);
+}
+
 int
-command_exec(struct arglist *args, int do_fork)
+command_exec(struct arglist *args, int do_fork, char **environment)
 {
        struct argument *arg;
-       static const char failed_exec_msg[] = "exec failed\n";
        char **argv, **argv2;
        int argc, status;
        pid_t child;
@@ -333,23 +348,26 @@
        if (real_path)
                setenv("PATH", real_path, 1);
 
-       if (do_fork)
-               child = vfork();
-       else
-               child = 0;
+       if (!do_fork)
+               command_child_exec(argv2);
 
-       switch (child) {
-       case 0:
-               execvp(exec_name, argv2);
-               status = write(STDERR_FILENO, failed_exec_msg,
-                   sizeof(failed_exec_msg) - 1);
-               _exit(255 | status);
-       case -1:
+#if defined(HAVE_POSIX_SPAWNP) && defined(HAVE_SPAWN_H)
+       status = posix_spawnp(&child, exec_name, NULL, NULL, argv2,
+           environment);
+       if (status) {
+               errno = status;
+               err(255, "posix_spawn failed");
+       }
+#else
+       child = vfork();
+
+       if (child == -1)
                err(255, "fork failed");
-       default:
-               waitpid(child, &status, 0);
-               return WEXITSTATUS(status);
-       }
+       if (child == 0)
+               command_child_exec(argv2);
+#endif
+       waitpid(child, &status, 0);
+       return WEXITSTATUS(status);
 }
 
 size_t
diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/files/bin/common.h
--- a/pkgtools/cwrappers/files/bin/common.h     Sun Nov 27 10:56:23 2016 +0000
+++ b/pkgtools/cwrappers/files/bin/common.h     Sun Nov 27 11:46:45 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.4 2015/04/19 13:30:35 tnn Exp $ */
+/* $NetBSD: common.h,v 1.5 2016/11/27 11:46:45 joerg Exp $ */
 
 /*-
  * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -58,7 +58,7 @@
 char   *concat2(const char *, const char *, size_t);
 void   arglist_from_argc(struct arglist *, int, char **);
 void   arglist_apply_config(struct arglist *);
-int    command_exec(struct arglist *, int);
+int    command_exec(struct arglist *, int, char **);
 size_t wrapper_hash(const char *);
 size_t wrapper_hash2(const char *, size_t);
 
diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/files/bin/config.h.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/cwrappers/files/bin/config.h.in  Sun Nov 27 11:46:45 2016 +0000
@@ -0,0 +1,55 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `posix_spawnp' function. */
+#undef HAVE_POSIX_SPAWNP
+
+/* Define to 1 if you have the <spawn.h> header file. */
+#undef HAVE_SPAWN_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
diff -r 15eabd2214a4 -r ba1fdd5cfa07 pkgtools/cwrappers/files/bin/configure
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/cwrappers/files/bin/configure    Sun Nov 27 11:46:45 2016 +0000
@@ -0,0 +1,4329 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for cwrappers 20161125.
+#
+# Report bugs to <joerg%NetBSD.org@localhost>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }



Home | Main Index | Thread Index | Old Index