AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-17120

Hari Sundararajan's questions

Martin Hope
Hari Sundararajan
Asked: 2018-10-30 17:23:27 +0800 CST

睡眠、等待和 Ctrl+C 传播

  • 9

如果我有以下 shell 脚本

sleep 30s

Ctrl+C当 shell 脚本运行时,我点击sleep了它,它就死了。

如果我有以下 shell 脚本

sleep 30s &
wait

我Ctrl+C在 shell 脚本运行时点击,sleep继续,现在有一个 1 的父级。

这是为什么?bash 不会传播Ctrl+C到所有孩子吗?

编辑:如果我有以下脚本

/usr/bin/Xvfb :18.0 -ac -screen 0 1180x980x24 &
wait

在我生成一个程序的地方,这次Ctrl+C在主进程上Xvfb也会杀死该进程。

那么如何/为什么Xvfb与睡眠不同?

在某些进程的情况下,我看到它们被 收割init,在某些情况下它们会死掉。为什么睡眠会被 init 收割?为什么会Xvfb死?

bash sleep
  • 3 个回答
  • 6472 Views
Martin Hope
Hari Sundararajan
Asked: 2018-10-19 03:28:40 +0800 CST

bash - 使用环境变量对文件描述符使用 exec

  • 0
LOCK_FD=200
LOCK_FILE=/tmp/lock-file
exec ${LOCK_FD}>${LOCK_FILE}

我收到一个错误

exec: 200 not found

然而,这有效

LOCK_FD=200
LOCK_FILE=/tmp/lock-file
eval "exec ${LOCK_FD}>${LOCK_FILE}"

知道为什么吗?

bash exec
  • 1 个回答
  • 615 Views
Martin Hope
Hari Sundararajan
Asked: 2018-10-10 00:08:31 +0800 CST

通过 ~/.ssh/config 多次更改主机名

  • 0

我的 ~/.ssh/config 中有以下设置

match host devbox 
 compression yes 
 user hari 
 port 22 
 hostname 192.168.9.7 

match originalhost devbox exec "~/.ssh/check_if_outside_home.sh" 
 hostname devbox.harisund.com 

想法是这样的——

  • 始终连接到 192.168.8.15(如果我已经在家庭网络中,这将起作用)
  • 如果我不在家庭局域网内,请连接到 devbox.harisund.com

但是,通过详细日志记录,我看到了这一点-

  1 OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016 
  2 debug1: Reading configuration data /home/hsundararaja/.ssh/config 
  3 debug2: checking match for 'host devbox' host devbox originally devbox 
  4 debug3: /home/hsundararaja/.ssh/config line 734: matched 'host "devbox"' 
  5 debug2: match found 
  6 debug2: checking match for 'originalhost devbox exec "~/.ssh/check_if_outside_home.sh"' host 192.168.9.7 originally devbox 
  7 debug3: /home/hsundararaja/.ssh/config line 744: matched 'originalhost "devbox"' 
  8 debug1: Executing command: '~/.ssh/check_if_outside_home.sh' 
  9 debug1: permanently_drop_suid: 14741 
 10 debug3: command returned status 0 
 11 debug3: /home/hsundararaja/.ssh/config line 744: matched 'exec "~/.ssh/check_if_outside_home.sh"' 
 12 debug2: match found 
 13 debug1: /home/hsundararaja/.ssh/config line 839: Applying options for * 
 14 debug1: Reading configuration data /etc/ssh/ssh_config 
 15 debug1: /etc/ssh/ssh_config line 19: Applying options for * 
 16 debug2: resolving "192.168.9.7" port 22 
 17 debug2: ssh_connect_direct: needpriv 0 
 18 debug1: Connecting to 192.168.9.7 [192.168.9.7] port 22. 
 19 debug2: fd 3 setting O_NONBLOCK 
 20 debug1: connect to address 192.168.9.7 port 22: Connection timed out 
 21 ssh: connect to host 192.168.9.7 port 22: Connection timed out 

在第 4 行,它检测到 ~/.ssh/config 中的第一节。此时,主机名更改为 192.168.9.7。到目前为止一切都很好。

在第 7 行,它到达第二节。

在第 8 行,它检查我们是否在家外,并返回 0。正如预期的那样。

第 12 行表示匹配,这意味着我们应该将主机名更改为 devbox.harisund.com

但是,在第 16 行,我们看到它仍然使用设置的本地主机名。

为什么 ?这是预期的行为吗?

ssh openssh
  • 1 个回答
  • 1176 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve