我正在移植一些bash脚本以在busybox上运行。他们使用disown
,在灰烬中不支持,然后杀死一些进程以防止来自该进程的消息出现在stdout / stderr中。我想保留这个功能。这是否意味着关闭stdout / sterr或在运行后重定向到/dev/null
。
怎么做?
答案 0 :(得分:1)
exec [n]>&-
将关闭FD [n]
。
答案 1 :(得分:0)
一旦进程从该进程外部运行,您就无法修改文件描述符的重定向。这意味着您必须在shell创建进程时执行重定向。无论是重定向到文件还是关闭像Ignacio这样的fds都取决于你。
我不确定为什么你认为bash的内置功能对文件描述符有任何影响。以下是bash手册的内容:
disown [-ar] [-h] [jobspec ...] Without options, each jobspec is removed from the table of active jobs. If jobspec is not present, and neither -a nor -r is supplied, the shell's notion of the current job is used. If the -h option is given, each jobspec is not removed from the ta- ble, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a job- spec does not specify a valid job.
但也许我对你想要达到的目标的理解是不完整的。