dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[Dotgnu-pnet-commits] pnet/engine lib_task.c,1.9,1.10


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnet/engine lib_task.c,1.9,1.10
Date: Fri, 31 Oct 2003 05:20:00 +0000

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv24480/engine

Modified Files:
        lib_task.c 
Log Message:


Pass environment variables from the "Process" class to the child
process (Unix systems).


Index: lib_task.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_task.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** lib_task.c  21 Jul 2003 03:50:35 -0000      1.9
--- lib_task.c  31 Oct 2003 05:19:57 -0000      1.10
***************
*** 571,574 ****
--- 571,576 ----
        const char *fname;
        char **args;
+       char **newEnviron = 0;
+       int varNum = 0;
        int stdinFds[2] = {-1, -1};
        int stdoutFds[2] = {-1, -1};
***************
*** 578,581 ****
--- 580,596 ----
        ILInt32 argc;
        const char *ansi;
+ #define       FreeStringList(list,size)       \
+               do { \
+                       if((list)) \
+                       { \
+                               int __posn = (int)(size); \
+                               while(__posn > 0) \
+                               { \
+                                       --__posn; \
+                                       ILFree((list)[__posn]); \
+                               } \
+                               ILFree((list)); \
+                       } \
+               } while (0)
  
        /* Convert the parameters into something that the OS can understand */
***************
*** 598,607 ****
                if(!ansi)
                {
!                       while(argc > 0)
!                       {
!                               --argc;
!                               ILFree(args[argc]);
!                       }
!                       ILFree(args);
                        return 0;
                }
--- 613,617 ----
                if(!ansi)
                {
!                       FreeStringList(args, argc);
                        return 0;
                }
***************
*** 609,618 ****
                if(!(args[argc]))
                {
!                       while(argc > 0)
!                       {
!                               --argc;
!                               ILFree(args[argc]);
!                       }
!                       ILFree(args);
                        return 0;
                }
--- 619,623 ----
                if(!(args[argc]))
                {
!                       FreeStringList(args, argc);
                        return 0;
                }
***************
*** 622,626 ****
        args[argc] = 0;
  
!       /* TODO: convert the environment */
  
        /* Redirect stdin, stdout, and stderr as necessary */
--- 627,662 ----
        args[argc] = 0;
  
!       /* Convert the environment */
!       if(envVars)
!       {
!               newEnviron = (char **)ILCalloc(envVars->length + 1, sizeof(char 
*));
!               if(!newEnviron)
!               {
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       FreeStringList(args, argc);
!                       return 0;
!               }
!               while(varNum < (int)(envVars->length))
!               {
!                       ansi = ILStringToAnsi
!                               (_thread, ((ILString 
**)ArrayToBuffer(envVars))[varNum]);
!                       if(!ansi)
!                       {
!                               FreeStringList(args, argc);
!                               FreeStringList(newEnviron, varNum);
!                               return 0;
!                       }
!                       newEnviron[varNum] = (char *)ILMalloc(strlen(ansi) + 1);
!                       if(!(newEnviron[varNum]))
!                       {
!                               FreeStringList(args, argc);
!                               FreeStringList(newEnviron, varNum);
!                               return 0;
!                       }
!                       strcpy(newEnviron[varNum], ansi);
!                       ++varNum;
!               }
!               newEnviron[varNum] = 0;
!       }
  
        /* Redirect stdin, stdout, and stderr as necessary */
***************
*** 699,702 ****
--- 735,743 ----
                        close(stderrFds[1]);
                }
+               if(newEnviron)
+               {
+                       extern char **environ;
+                       environ = newEnviron;
+               }
                execvp(fname, args);
                exit(1);
***************
*** 741,750 ****
  
        /* Clean up and exit */
!       while(argc > 0)
!       {
!               --argc;
!               ILFree(args[argc]);
!       }
!       ILFree(args);
        return result;
  
--- 782,787 ----
  
        /* Clean up and exit */
!       FreeStringList(args, argc);
!       FreeStringList(newEnviron, varNum);
        return result;
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]