Bug 17844 – std.process.execute should allow not capturing stderr

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-09-20T10:15:21Z
Last change time
2021-04-19T16:44:30Z
Keywords
pull
Assigned to
No Owner
Creator
Vladimir Panteleev

Comments

Comment #0 by dlang-bugzilla — 2017-09-20T10:15:21Z
Currently, std.process.execute returns in its output a mix of the executed process's stdout and stderr output. However, capturing stderr is not always desirable. In fact, unless the D program invoking std.process.execute needs to parse the child process's error messages, or needs to relay the error output of the child process to the user (as it would otherwise not be visible), it is not necessary, and potentially dangerous, as the program might confuse or attempt to parse the program's error output as its produced output. Compare this to the common shell pattern of redirecting a program's output to a file: $ program > output.txt In this manner, should the program fail, the command will complete with a non-zero exit status, and any error messages emitted by the program will be directly visible to the user. D's execute behaviour is as follows: $ program > output.txt 2>&1 This mixes output and error streams. If the invoking program or script is not careful to check the error code, and attempts to process the program's output (which now contains error messages mixed in), it can cause such garbage data to propagate further than desired. This is especially egregious if the child program writes informational messages (warnings) to stderr, which do not affect the correctness of the output (on stdout) or the exit status. In such a case, it becomes impossible to use std.process.execute correctly. In some circumstances, such messages can be printed only in some cases (for example, image processing libraries such as gd, or text encoding conversion libraries such as iconv, will only print warnings to stderr on malformed data), which may cause bugs in D programs only discovered in production. Thus, std.process.execute needs to be changed to allow stderr to be passed to the invoking D program's stderr, and only capture stdout (probably via a Config flag).
Comment #1 by dlang-bugzilla — 2017-09-20T10:27:33Z
Comment #2 by github-bugzilla — 2017-09-22T13:33:29Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/71adbeee85f4f97d5b3cf93bed28c0f4779e2d23 Fix Issue 17844 - std.process.execute should allow not capturing stderr https://github.com/dlang/phobos/commit/5b5bc615cdebca8b909e70b0e33cde6ffe594376 Merge pull request #5742 from CyberShadow/pull-20170920-102045 Fix Issue 17844 - std.process.execute should allow not capturing stderr merged-on-behalf-of: Steven Schveighoffer <[email protected]>
Comment #3 by github-bugzilla — 2017-10-16T09:58:05Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/71adbeee85f4f97d5b3cf93bed28c0f4779e2d23 Fix Issue 17844 - std.process.execute should allow not capturing stderr https://github.com/dlang/phobos/commit/5b5bc615cdebca8b909e70b0e33cde6ffe594376 Merge pull request #5742 from CyberShadow/pull-20170920-102045
Comment #4 by dlang-bot — 2021-04-19T16:44:30Z
dlang/phobos pull request #7984 "[dmd-cxx] Fix Issue 17844 - std.process.execute should allow not capturing stderr " was merged into dmd-cxx: - 9f6b86f7aea0e3ac34bb78718905fa79c469de5f by Vladimir Panteleev: Fix Issue 17844 - std.process.execute should allow not capturing stderr https://github.com/dlang/phobos/pull/7984