小编use*_*310的帖子

如果分配了伪tty,为什么在ssh上运行后台任务会失败?

在ssh上运行命令时,我最近遇到了一些奇怪的行为.我有兴趣听到下面这种行为的任何解释.

正在运行ssh localhost 'touch foobar &'创建一个名为expect的文件foobar:

[bob@server ~]$ ssh localhost 'touch foobar &'
[bob@server ~]$ ls foobar
foobar
Run Code Online (Sandbox Code Playgroud)

但是,运行相同的命令但使用-t强制伪tty分配选项无法创建foobar:

[bob@server ~]$ ssh -t localhost 'touch foobar &'
Connection to localhost closed.
[bob@server ~]$ echo $?
0
[bob@server ~]$ ls foobar
ls: cannot access foobar: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我目前的理论是,由于触摸过程正在被覆盖,因此伪进程在进程有机会运行之前被分配和未分配.当然,添加一秒睡眠可让触摸按预期运行:

[bob@pidora ~]$ ssh -t localhost 'touch foobar & sleep 1'
Connection to localhost closed.
[bob@pidora ~]$ ls foobar
foobar
Run Code Online (Sandbox Code Playgroud)

如果有人有明确的解释,我会非常有兴趣听到它.谢谢.

ssh bash jobs tty pty

17
推荐指数
1
解决办法
3557
查看次数

在javascript中实现一个方形树形图

我目前正在尝试在Javascript中实现树图算法.更具体地说,在Squarified Treemaps中描述的算法.给出的伪代码如下所示:

procedure squarify(list of real children, list of real row, real w)
begin
    real c = head(children);
    if worst(row, w) <= worst(row++[c], w) then
        squarify(tail(children),row++[c], w)
    else
        layoutrow(row);
        squarify(children,[], width());
    fi
end
Run Code Online (Sandbox Code Playgroud)

但我的JavaScript看起来像:

var c = children[0];
if (worst(row, w) >= worst(row.concat(c), w)) {
    this.squarify(children.splice(1), row.concat(c), w);
} else {
    layoutrow(row);
    this.squarify(children, [], width());
}
Run Code Online (Sandbox Code Playgroud)

据我所知,我的代码工作正常,但不平等是错误的方法.我假设我在实现中忽略了某些东西,或者伪代码中的不等式是不正确的?谢谢

javascript algorithm pseudocode treemap

8
推荐指数
1
解决办法
7981
查看次数

标签 统计

algorithm ×1

bash ×1

javascript ×1

jobs ×1

pseudocode ×1

pty ×1

ssh ×1

treemap ×1

tty ×1