/ proc / self和/ proc / $$有什么区别?

时间:2019-05-29 08:24:14

标签: linux bash shell

我以前认为Error:(15, 8) inferred type arguments [?1,?0] do not conform to method flatMap's type parameter bounds [KR,VR] .flatMap( Error:(16, 20) type mismatch; found : org.apache.kafka.streams.kstream.KeyValueMapper[String,Option[org.minsait.streams.model.JsonMessage],Iterable[org.apache.kafka.streams.KeyValue[String,String]]] required: org.apache.kafka.streams.kstream.KeyValueMapper[_ >: String, _ >: Option[org.minsait.streams.model.JsonMessage], _ <: Iterable[_ <: org.apache.kafka.streams.KeyValue[_ <: KR, _ <: VR]]] (key, value) => toFormattedEvents(key, value) /proc/self在bash终端中是相同的,但是现在我发现它们是不同的。

我知道/proc/$$表示当前进程的pid,而$$是当前正在运行的进程,它应该是bash终端。为什么它们不同?

/proc/self

1 个答案:

答案 0 :(得分:2)

$$是一个特殊的bash变量,已扩展为外壳的pid。

/proc/self是指向进行呼叫的进程的/proc/子目录的 real 符号链接。

当您执行ls /proc/$$时,shell会将其扩展为ls /proc/pid-of-bash,这就是您所看到的shell过程的内容。

但是,当您执行ls /proc/self时,您会看到短暂的ls流程的内容。

$$不限于此用法,您可以编写echo $$来查看bash pid;您可以用它杀死自己等等。

相关问题