gpt4 book ai didi

bash - Trap 命令未检测终端大小调整 (SIGWINCH)

转载 作者:行者123 更新时间:2023-12-03 08:32:44 25 4
gpt4 key购买 nike

我试图使用 trap "echo resized" SIGWINCH 检测我的菜单何时调整大小但它似乎没有检测到它。我目前使用的是 ubuntu 20.04,并且我正在使用 bash 脚本来执行此操作。trap 命令位于我的脚本的顶部。为什么不执行?

最佳答案

根据 bash 手册 (man bash):

If bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes.

您可以通过以下方式验证:

trap 'echo resized' SIGWINCH

while true; do
sleep 1
done

关于bash - Trap 命令未检测终端大小调整 (SIGWINCH),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64728409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com