We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Summary: Environment variables disappear when the program forks when debugging a C++ program
VScode gets rid of environment variables when I debug a C++ programs which forks.
Here is an example with a 2 files project :
hello1.cpp
#include <boost/process.hpp> namespace ps = boost::process; int main() { std::string command = "/home/user/MyProject/hello2"; ps::child c(command); c.wait(); return 0; }
hello2.cpp
#include <iostream> int main() { std::cout << "Hello world" << std::endl; const char* myVarEnv = std::getenv("FOO"); std::cout << "myVarEnv = " << myVarEnv << std::endl; return 0; }
to build hello1.cpp and hello2.cpp :
g++ -g hello1.cpp -o hello1 -lpthread g++ -g hello2.cpp -o hello2
What is astonishing is when I debug hello1 I can see my FOO environment variable is correctly defined :
-exec show environment FOO FOO = foo
Then I switch the follow-fork-mode to child :
-exec set follow-fork-mode child
But when I fork in hello2, gdb can't find the FOO environment variable anymore :
-exec show environment FOO Environment variable "FOO" not defined.
but oddly enough, the program hello2 manages to print the environment variable correctly :
myVarEnv = foo
Moreover, if I debug this program with gdb, gdb can find the FOO environment variable perfectly in both hello1 and hello2 :
(gdb) show environment FOO FOO = foo
Since, VScode just uses gdb, that means VScode should be able to find the FOO environment normally, right ?
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "/home/user/MyProject/hello1", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [ {"name": "FOO", "value": "foo"} ], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "Set Disassembly Flavor to Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] } ] }
Hello world myVarEnv = foo [1] + Done
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Environment
Bug Summary and Steps to Reproduce
Bug Summary: Environment variables disappear when the program forks when debugging a C++ program
VScode gets rid of environment variables when I debug a C++ programs which forks.
Here is an example with a 2 files project :
hello1.cpp
hello2.cpp
to build hello1.cpp and hello2.cpp :
What is astonishing is when I debug hello1 I can see my FOO environment variable is correctly defined :
Then I switch the follow-fork-mode to child :
-exec set follow-fork-mode child
But when I fork in hello2, gdb can't find the FOO environment variable anymore :
but oddly enough, the program hello2 manages to print the environment variable correctly :
myVarEnv = foo
Moreover, if I debug this program with gdb, gdb can find the FOO environment variable perfectly in both hello1 and hello2 :
Since, VScode just uses gdb, that means VScode should be able to find the FOO environment normally, right ?
Debugger Configurations
Debugger Logs
Other Extensions
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: