Preemptively unset WAYLAND_DISPLAY

This commit is contained in:
Robbert van der Helm
2023-02-25 15:22:23 +01:00
parent 3bab9c3d6b
commit a35cd8da50
6 changed files with 41 additions and 0 deletions
+7
View File
@@ -174,6 +174,13 @@ void ProcessEnvironment::insert(const std::string& key,
variables_.push_back(key + "=" + value);
}
size_t ProcessEnvironment::erase(const std::string& key) {
return std::erase_if(variables_, [&key](const std::string& variable) {
return variable.starts_with(key) && variable.size() > key.size() &&
variable[key.size()] == '=';
});
}
char* const* ProcessEnvironment::make_environ() const {
recreated_environ_.clear();
+8
View File
@@ -101,6 +101,14 @@ class ProcessEnvironment {
*/
void insert(const std::string& key, const std::string& value);
/**
* Remove an environment variable from the environment. Returns the number
* of elements erased (to stay consistent with the STL map interface). This
* can be higher than 1 if the map contains duplicate or overwritten
* environment variables.
*/
size_t erase(const std::string& key);
/**
* Create an environ-like object from the updated environment that can be
* passed to the `exec*e()` functions. These pointers will be invalidated