开发者

lsof not giving o/p for bash built in read

开发者 https://www.devze.com 2023-03-14 01:50 出处:网络
When I do find / on a terminal and then do on another terminal lsof -a -d 0-2 -c fin I see o/p listed from execution of lsof command.

When I do

find /

on a terminal and then do on another terminal

lsof -a -d 0-2 -c fin

I see o/p listed from execution of lsof command.

But when I do

echo hi ; read -t 30 hello
hi

on the same terminal ( as find) and do (on different terminal)

lsof -a -d 0-2 -c read

I don't get an开发者_运维知识库y output from lsof command

Why ? Is it because read is bash built in ? Whats happening here ?


You got it right. "read" is a shell built-in. The process name remains sh (or bash, or zsh, or whatever else is your shell of choice).

Moreover, though for some shell built-ins there are binary alternatives, there isn't one for read. Really because of its syntax, it takes in the name of a shell variable that gets assigned the result of reading from the stdin. If it was an external program, it could never set the variable in the calling shell.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号