lsof 的非零退出代码
Non zero exit code for lsof
我正在使用以下 lsof
命令:
lsof -iTCP -a -sTCP:^LISTEN -a -p <pid>
如果此命令有一些输出 returns 退出代码 0
但如果没有输出则退出代码为 1
.
echo $?
谁能解释为什么会这样?有办法避免吗?
这是预期的行为:如果找到某些内容,您只会得到 0
。
来自man lsof
:
DIAGNOSTICS
Errors are identified with messages on the standard error file.
Lsof returns a one (1) if any error was detected, including the
failure to locate command names, file names, Internet addresses
or files, login names, NFS files, PIDs, PGIDs, or UIDs it was asked
to list. If the -V option is specified, lsof will indicate the search
items it failed to list.
It returns a zero (0) if no errors were detected and if it was able to list some information about all the specified search arguments.
我正在使用以下 lsof
命令:
lsof -iTCP -a -sTCP:^LISTEN -a -p <pid>
如果此命令有一些输出 returns 退出代码 0
但如果没有输出则退出代码为 1
.
echo $?
谁能解释为什么会这样?有办法避免吗?
这是预期的行为:如果找到某些内容,您只会得到 0
。
来自man lsof
:
DIAGNOSTICS
Errors are identified with messages on the standard error file.
Lsof returns a one (1) if any error was detected, including the failure to locate command names, file names, Internet addresses or files, login names, NFS files, PIDs, PGIDs, or UIDs it was asked to list. If the -V option is specified, lsof will indicate the search items it failed to list.
It returns a zero (0) if no errors were detected and if it was able to list some information about all the specified search arguments.