 |
Changeset 1954
- 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
| r1945 |
r1954 |
|
| 8 | 8 | |
|---|
| 9 | 9 | private import tango.io.FileConst; |
|---|
| 10 | | private import tango.io.Stdout; |
|---|
| | 10 | private import tango.io.Console; |
|---|
| 11 | 11 | private import tango.io.Buffer; |
|---|
| 12 | 12 | private import tango.sys.Common; |
|---|
| … | … | |
| 26 | 26 | private import tango.stdc.posix.unistd; |
|---|
| 27 | 27 | private import tango.stdc.posix.sys.wait; |
|---|
| | 28 | } |
|---|
| | 29 | |
|---|
| | 30 | debug (Process) |
|---|
| | 31 | { |
|---|
| | 32 | private import tango.io.Stdout; |
|---|
| 28 | 33 | } |
|---|
| 29 | 34 | |
|---|
| … | … | |
| 769 | 774 | // the format expected by the execv() family of functions. |
|---|
| 770 | 775 | argptr = toNullEndedArray(_args); |
|---|
| 771 | | envptr = toNullEndedArray(_env); |
|---|
| | 776 | envptr = (_env.length > 0 ? toNullEndedArray(_env) : null); |
|---|
| 772 | 777 | |
|---|
| 773 | 778 | // Switch to the working directory if it has been set. |
|---|
| … | … | |
| 783 | 788 | if (rc == -1) |
|---|
| 784 | 789 | { |
|---|
| 785 | | Stderr.formatln("Failed to exec {0}: {1}", |
|---|
| 786 | | _args[0], SysError.lastMsg); |
|---|
| | 790 | Cerr("Failed to exec ")(_args[0])(": ")(SysError.lastMsg).newline; |
|---|
| 787 | 791 | |
|---|
| 788 | 792 | try |
|---|
| … | … | |
| 802 | 806 | else |
|---|
| 803 | 807 | { |
|---|
| 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; |
|---|
| 806 | 810 | exit(errno); |
|---|
| 807 | 811 | } |
|---|
| … | … | |
| 1345 | 1349 | path ~= FileConst.PathSeparatorChar; |
|---|
| 1346 | 1350 | } |
|---|
| | 1351 | |
|---|
| | 1352 | debug (Process) |
|---|
| | 1353 | Stdout.formatln("Trying execution of '{0}' in directory '{1}'", |
|---|
| | 1354 | filename, path); |
|---|
| | 1355 | |
|---|
| 1347 | 1356 | 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)); |
|---|
| 1350 | 1360 | // If the process execution failed because of an error |
|---|
| 1351 | 1361 | // other than ENOENT (No such file or directory) we |
|---|
| … | … | |
| 1359 | 1369 | else |
|---|
| 1360 | 1370 | { |
|---|
| 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)); |
|---|
| 1362 | 1377 | } |
|---|
| 1363 | 1378 | return rc; |
|---|
| … | … | |
| 1471 | 1486 | catch (ProcessException e) |
|---|
| 1472 | 1487 | { |
|---|
| 1473 | | Stdout.formatln("Program execution failed: {0}", e.toUtf8()); |
|---|
| | 1488 | Cerr("Program execution failed: ")(e.toUtf8()).newline(); |
|---|
| 1474 | 1489 | } |
|---|
| 1475 | 1490 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic