[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[gstein@apache.org: cvs commit: apr/threadproc/win32 proc.c]

From: Greg Stein <gstein_at_lyra.org>
Date: 2002-01-29 01:47:16 CET

Got this done a couple hours ago... svn_io_run_cmd() now has some new APR
functionality to use :-)

----- Forwarded message from gstein@apache.org -----

From: gstein@apache.org
Subject: cvs commit: apr/threadproc/win32 proc.c
To: apr-cvs@apache.org
Date: 28 Jan 2002 21:58:16 -0000
Reply-To: dev@apr.apache.org

gstein 02/01/28 13:58:16

  Modified: include apr_thread_proc.h
               threadproc/beos proc.c
               threadproc/netware proc.c
               threadproc/os2 proc.c
               threadproc/unix proc.c
               threadproc/win32 proc.c
  Log:
  Add a couple new command types to process creation:
  
      APR_PROGRAM_ENV: start the program using the caller's environment
      APR_PROGRAM_PATH: search PATH for the program, use caller's env
  
  (the normal APR_PROGRAM isolates the env and does not use PATH)
  
  The BeOS, OS/2, and Win32 implementations are incomplete. These two
  new forms just default back to APR_PROGRAM for now. (although BeOS
  doesn't even distinguish between APR_SHELLCMD and APR_PROGRAM!)
  
  On Unix and Netware, these map into execv() and execvp() calls.
  
  Also clarified some doc for the enums in apr_thread_proc.h a bit.
  
  Revision Changes Path
  1.79 +25 -8 apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- apr_thread_proc.h 27 Dec 2001 17:02:59 -0000 1.78
  +++ apr_thread_proc.h 28 Jan 2002 21:58:15 -0000 1.79
  @@ -71,7 +71,7 @@
   #endif /* __cplusplus */
   /**
    * @file apr_thread_proc.h
  - * @brief APR Thread Library
  + * @brief APR Thread and Process Library
    */
   /**
    * @defgroup APR_Thread Thread Library
  @@ -79,15 +79,28 @@
    * @{
    */
   
  -typedef enum {APR_SHELLCMD, APR_PROGRAM} apr_cmdtype_e;
  -typedef enum {APR_WAIT, APR_NOWAIT} apr_wait_how_e;
  +typedef enum {
  + APR_SHELLCMD, /**< use the shell to invoke the program */
  + APR_PROGRAM, /**< invoke the program directly, no copied env */
  + APR_PROGRAM_ENV, /**< invoke the program, replicating our environment */
  + APR_PROGRAM_PATH /**< find program on PATH, use our environment */
  +} apr_cmdtype_e;
  +
  +typedef enum {
  + APR_WAIT, /**< wait for the specified process to finish */
  + APR_NOWAIT /**< do not wait -- just see if it has finished */
  +} apr_wait_how_e;
  +
   /* I am specifically calling out the values so that the macros below make
    * more sense. Yes, I know I don't need to, but I am hoping this makes what
    * I am doing more clear. If you want to add more reasons to exit, continue
    * to use bitmasks.
    */
  -typedef enum {APR_PROC_EXIT = 1, APR_PROC_SIGNAL = 2,
  - APR_PROC_SIGNAL_CORE = 4} apr_exit_why_e;
  +typedef enum {
  + APR_PROC_EXIT = 1, /**< process exited normally */
  + APR_PROC_SIGNAL = 2, /**< process exited due to a signal */
  + APR_PROC_SIGNAL_CORE = 4 /**< process exited and dumped a core file */
  +} apr_exit_why_e;
   
   #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT)
   #define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL)
  @@ -428,8 +441,10 @@
    * @param attr The procattr we care about.
    * @param cmd The type of command. One of:
    * <PRE>
  - * APR_SHELLCMD -- Shell script
  - * APR_PROGRAM -- Executable program (default)
  + * APR_SHELLCMD -- Shell script
  + * APR_PROGRAM -- Executable program (default)
  + * APR_PROGRAM_ENV -- Executable program, copy environment
  + * APR_PROGRAM_PATH -- Executable program on PATH, copy env
    * </PRE>
    */
   APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr,
  @@ -477,7 +492,9 @@
    * @param const_args the arguments to pass to the new program. The first
    * one should be the program name.
    * @param env The new environment table for the new process. This
  - * should be a list of NULL-terminated strings.
  + * should be a list of NULL-terminated strings. This argument
  + * is ignored for APR_PROGRAM_ENV and APR_PROGRAM_PATH types
  + * of commands.
    * @param attr the procattr we should use to determine how to create the new
    * process
    * @param cont The pool to use.
  
  
  
  1.44 +2 -0 apr/threadproc/beos/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- proc.c 14 Dec 2001 01:12:25 -0000 1.43
  +++ proc.c 28 Jan 2002 21:58:15 -0000 1.44
  @@ -249,6 +249,8 @@
       }
       newargs[nargs] = NULL;
   
  + /* ### we should be looking at attr->cmdtype in here... */
  +
       newproc = load_image(nargs, (const char**)newargs, (const char**)env);
   
       /* load_image copies the data so now we can free it... */
  
  
  
  1.5 +14 -1 apr/threadproc/netware/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- proc.c 8 Jan 2002 21:00:37 -0000 1.4
  +++ proc.c 28 Jan 2002 21:58:15 -0000 1.5
  @@ -349,11 +349,24 @@
               }
               execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
           }
  - else {
  + else if (attr->cmdtype == APR_PROGRAM) {
               if (attr->detached) {
                   apr_proc_detach();
               }
               execve(progname, (char * const *)args, (char * const *)env);
  + }
  + else if (attr->cmdtype == APR_PROGRAM_ENV) {
  + if (attr->detached) {
  + apr_proc_detach();
  + }
  + execv(progname, (char * const *)args);
  + }
  + else {
  + /* APR_PROGRAM_PATH */
  + if (attr->detached) {
  + apr_proc_detach();
  + }
  + execvp(progname, (char * const *)args);
           }
           exit(-1); /* if we get here, there is a problem, so exit with an */
                      /* error code. */
  
  
  
  1.48 +2 -0 apr/threadproc/os2/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- proc.c 26 Oct 2001 02:31:04 -0000 1.47
  +++ proc.c 28 Jan 2002 21:58:15 -0000 1.48
  @@ -345,6 +345,8 @@
       if (extension == NULL || strchr(extension, '/') || strchr(extension, '\\'))
           extension = "";
   
  + /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */
  +
       if (attr->cmdtype == APR_SHELLCMD || strcasecmp(extension, ".cmd") == 0) {
           strcpy(interpreter, "#!" SHELL_PATH);
           extra_arg = "/C";
  
  
  
  1.55 +14 -1 apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- proc.c 25 Jan 2002 02:21:43 -0000 1.54
  +++ proc.c 28 Jan 2002 21:58:15 -0000 1.55
  @@ -366,11 +366,24 @@
               }
               execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
           }
  - else {
  + else if (attr->cmdtype == APR_PROGRAM) {
               if (attr->detached) {
                   apr_proc_detach();
               }
               execve(progname, (char * const *)args, (char * const *)env);
  + }
  + else if (attr->cmdtype == APR_PROGRAM_ENV) {
  + if (attr->detached) {
  + apr_proc_detach();
  + }
  + execv(progname, (char * const *)args);
  + }
  + else {
  + /* APR_PROGRAM_PATH */
  + if (attr->detached) {
  + apr_proc_detach();
  + }
  + execvp(progname, (char * const *)args);
           }
           exit(-1); /* if we get here, there is a problem, so exit with an */
                      /* error code. */
  
  
  
  1.62 +2 -0 apr/threadproc/win32/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- proc.c 28 Jan 2002 15:56:08 -0000 1.61
  +++ proc.c 28 Jan 2002 21:58:16 -0000 1.62
  @@ -343,6 +343,8 @@
           i++;
       }
   
  + /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */
  +
       if (attr->cmdtype == APR_SHELLCMD) {
           char *shellcmd = getenv("COMSPEC");
           if (!shellcmd)
  
  
  

----- End forwarded message -----

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:00 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.