Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 1954

Show
Ignore:
Timestamp:
03/22/07 19:06:30 (2 years ago)
Author:
jcomellas
Message:

* Removed dependency on tango.io.Stdout for non-debug builds.
* On POSIX platforms, the environment was not being passed correctly to child

processes. This commit should fix ticket #348.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/sys/Process.d

    r1945 r1954  
    88 
    99private import tango.io.FileConst; 
    10 private import tango.io.Stdout
     10private import tango.io.Console
    1111private import tango.io.Buffer; 
    1212private import tango.sys.Common; 
     
    2626    private import tango.stdc.posix.unistd; 
    2727    private import tango.stdc.posix.sys.wait; 
     28} 
     29 
     30debug (Process) 
     31{ 
     32    private import tango.io.Stdout; 
    2833} 
    2934 
     
    769774                        // the format expected by the execv() family of functions. 
    770775                        argptr = toNullEndedArray(_args); 
    771                         envptr = toNullEndedArray(_env); 
     776                        envptr = (_env.length > 0 ? toNullEndedArray(_env) : null); 
    772777 
    773778                        // Switch to the working directory if it has been set. 
     
    783788                        if (rc == -1) 
    784789                        { 
    785                             Stderr.formatln("Failed to exec {0}: {1}", 
    786                                             _args[0], SysError.lastMsg); 
     790                            Cerr("Failed to exec ")(_args[0])(": ")(SysError.lastMsg).newline; 
    787791 
    788792                            try 
     
    802806                    else 
    803807                    { 
    804                         Stderr.formatln("Failed to set notification pipe to close-on-exec for {0}: {1}", 
    805                                         _args[0], SysError.lastMsg)
     808                        Cerr("Failed to set notification pipe to close-on-exec for ") 
     809                            (_args[0])(": ")(SysError.lastMsg).newline
    806810                        exit(errno); 
    807811                    } 
     
    13451349                        path ~= FileConst.PathSeparatorChar; 
    13461350                    } 
     1351 
     1352                    debug (Process) 
     1353                        Stdout.formatln("Trying execution of '{0}' in directory '{1}'", 
     1354                                        filename, path); 
     1355 
    13471356                    path ~= filename; 
    1348  
    1349                     rc = execve(path.ptr, argv.ptr, envp.ptr); 
     1357                    path ~= '\0'; 
     1358 
     1359                    rc = execve(path.ptr, argv.ptr, (envp.length > 0 ? envp.ptr : null)); 
    13501360                    // If the process execution failed because of an error 
    13511361                    // other than ENOENT (No such file or directory) we 
     
    13591369            else 
    13601370            { 
    1361                 rc = execve(argv[0], argv.ptr, envp.ptr); 
     1371                debug (Process) 
     1372                    Stdout.formatln("Calling execve('{0}', argv[{1}], {2})", 
     1373                                    (argv[0])[0 .. strlen(argv[0])], 
     1374                                    argv.length, (envp.length > 0 ? "envp" : "null")); 
     1375 
     1376                rc = execve(argv[0], argv.ptr, (envp.length > 0 ? envp.ptr : null)); 
    13621377            } 
    13631378            return rc; 
     
    14711486        catch (ProcessException e) 
    14721487        { 
    1473             Stdout.formatln("Program execution failed: {0}", e.toUtf8()); 
     1488            Cerr("Program execution failed: ")(e.toUtf8()).newline(); 
    14741489        } 
    14751490    }