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-136276

The Quark's questions

Martin Hope
The Quark
Asked: 2021-11-14 12:34:27 +0800 CST

具有自己的 $BASHPID 的子shell(子进程/子进程)未由 `ps` 列出

  • 1

我不明白以下内容:

mkfifo p;
$ (>p ps -f | >>p echo $BASHPID) &
[1] 983527
$ cat p
983529
   PID    PPID  C STIME TTY          TIME CMD
981815  165343  0 19:57 pts/27   00:00:00 bash
983527  981815  0 21:09 pts/27   00:00:00 bash    # <- child bash process `(...)`
983528  983527  0 21:09 pts/27   00:00:00 ps -f
983530  981815  0 21:09 pts/27   00:00:00 cat p

(...) &产生一个 PID 为 983527 的子进程。它是一个 bash 进程。

ps -f在 PID 为 983528的子进程中执行。(...)它是管道的左侧组件命令...|...。

echo $BASHPID报告将在 PID 983529 的进程中执行。它应该是管道的右侧组件,...|...并且应该被列为 bash 进程。

最后的解释正确吗?为什么我们看不到ps -f命令​​列出的最后一个进程?

bash process
  • 1 个回答
  • 74 Views
Martin Hope
The Quark
Asked: 2021-11-12 13:54:28 +0800 CST

没有子shell进程的子shell示例

  • 0

我最近才了解到“子shell”与“子shell进程”不同(例如参见“子shell”和“子进程”之间的确切区别是什么?以及子shell和子进程的POSIX定义)。

为了让自己相信这一点,我正在寻找一个命令来说明(证明)子shell 是在没有产生子shell 的情况下创建的。

现在,我尝试的一切似乎都会在创建子shell时产生一个子shell:

$ echo $BASHPID; (pwd; cd ..; echo $BASHPID; pwd); pwd      # `( ...)` executed in a subshell
                                                            # and in a child-shell process

$ >&2 ps | ps       # Theoretically executed in two subshells and apparently without child-shells
                    # but I cannot be sure due to the outcome of the next example

$ $ >&2 echo $BASHPID | ps      # `ps` doesn't display a child-shell for the execution of `echo`
953790                          # but `echo $BASHPID` shows a new process that is necessarily
    PID TTY         TIME CMD    # a child-shell since echo is a built-in 
 948538 pts/2   00:00:00 bash
 953791 pts/2   00:00:00 ps

我正在寻找一种方法来证明拥有子外壳并不一定意味着拥有子外壳......

重击 5.0.17

bash shell
  • 2 个回答
  • 235 Views
Martin Hope
The Quark
Asked: 2021-09-15 13:34:16 +0800 CST

`${parameter#word}` 和 `${parameter##word}` 之间的区别?

  • -1

根据man bash:

${parameter#word}  
${parameter##word}
    Remove matching prefix pattern. The word is expanded to produce a
    pattern just as in pathname expansion, and matched against the
    expanded value of parameter using the rules described under Pattern
    Matching below. If the pattern matches the beginning of the value of
    parameter, then the result of the expansion is the expanded value of
    parameter with the shortest matching pattern (the ``#'' case) or the
    longest matching pattern (the ``##'' case) deleted. If parameter is
    @ or *, the pattern removal operation is applied to each positional
    parameter in turn, and the expansion is the resultant list.  If
    parameter is an array variable subscripted with @ or *, the pattern
    removal operation is applied to each member of the array in turn,
    and the expansion is the resultant list.

不知何故,我找不到在${parameter#word}和之间给出不同结果的情况${parameter##word}。

我正在寻找能够说明两种语法之间不同行为的情况。顺便说一句,什么是最短匹配模式,什么是最长匹配模式?

bash
  • 2 个回答
  • 183 Views
Martin Hope
The Quark
Asked: 2019-05-26 05:21:11 +0800 CST

Git包破坏了bash完成?

  • 1

我即将尝试安装 git 包。在 Synaptic 的依赖项选项卡中,它写道:

  • 休息:bash 完成 (<1:1.9-1)
  • Breaks : bash-completion [斜体]

我安装了存储库提供的最新版本的 bash-completion(版本 1:2.8-1ubuntu1)。

我读过 git 带有一些经过调整的自动完成功能,我猜这个功能实际上不会阻止完成在 bash 中工作,对吧?

此外,该apt-get -s install git命令不会输出有关 bash-completion 包的任何内容。

所以我的问题是:

  • 由于我已经安装了最新版本的 bash-completion 包,在安装 git 的特殊情况下会发生什么?
  • 在这个特定的上下文中,斜体的第二行是什么意思?这两行有何不同且未合并到一个“ Breaks : bash-completion”行中?

编辑(附加信息)

  • 我有 Linux Mint 19.1(Ubuntu 18.04 基础)
  • 该存储库提供 git 1:2.17.1-1ubuntu0.4
bash git
  • 1 个回答
  • 83 Views
Martin Hope
The Quark
Asked: 2019-05-24 13:25:06 +0800 CST

已安装文件系统上的 set-user-ID 和 set-group-ID 位(suid 与 nosuid 选项)的未确定状态?

  • 0

的手册页mount指示:

suid    Allow set-user-ID or set-group-ID bits to take effect.

nosuid  Do not allow set-user-ID or set-group-ID bits to take effect.

但没有迹象表明这些选项中的一个或另一个是默认选项。

同时,我找不到任何关于我的根文件系统的suid或状态的信息:nosuid

  • 如果我执行命令$ mount,我会得到:

/dev/sda2 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered).

  • 我在文件中看不到任何suid或nosuid选项/etc/fstab。

  • 其中/proc/mounts仅表示:

/dev/sda2 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0.

  • mkfs.ext4我在 or 的手册页或tune2fs文件中找不到任何内容/etc/mke2fs.conf。

所以我的问题是:

  • 安装 filsystem 时的状态suid或选择如何?nosuid
  • 在哪里可以找到已挂载文件系统的状态suid或状态?nosuid
mount automounting
  • 1 个回答
  • 295 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