删除kdb实例中的环境变量

huangapple go评论81阅读模式
英文:

Deleting environment variables within kdb instance

问题

如何在kdb实例内取消设置环境变量?

我可以执行setenv[`abc;""],这将在kdb中产生与不存在一样的输出,但在幕后,环境变量实际上是否被删除,还是只是被设置为空?

另外,系统命令是否在单独的操作系统终端中运行?

q)setenv[`acc;321]
q)getenv`acc
"321"
q)system"unset acc"
q)getenv`acc
"321"

类似地:

q)system"export adc=123; echo $adc"
"123"
q)system"echo $adc"
""
英文:

How can I unset environment variables within a kdb instance?

I can do setenv[`abc;""] which will give the same output in kdb as if it doesn't exist, but behind the scenes is the environment variable actually deleted, or is it just set to be empty?

Also, does the system command run in a separate OS terminal?

q)setenv[`acc;321]
q)getenv`acc
"321"
q)system"unset acc"
q)getenv`acc
"321"

similarly:

q)system"export adc=123; echo $adc"
"123"
q)system"echo $adc"
""

答案1

得分: 2

我不确定您是否可以按您概述的方式删除在q中定义的环境变量。

环境变量是否实际删除,还是只是设置为空?

它只是设置为空,即在进程中仍然定义。

使用 strace -tTy -p <pid> 您可以看到在运行系统命令时例如 vfork 被利用,即系统调用在临时子进程中执行。

英文:

I'm not sure if you can remove an environment variable defined in q as you've outlined.

> is the environment variable actually deleted, or is it just set to be empty?

It's just set to empty i.e. still defined on the process.

Using strace -tTy -p &lt;pid&gt; you can see when running system commands that e.g. vfork is utilised, in that system calls are executed in a temporary child clone.

huangapple
  • 本文由 发表于 2023年7月18日 01:33:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76706851.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定