在Electron中,渲染器进程的pid被暴露出来
processId = require('remote').getCurrentWindow().getProcessId()
但是,它在最近的版本中不再有效(1.4.x,1.5.x,1.6.x).
有没有其他方法来获取渲染器进程的pid,即Windows的pid?
解决方法:
奇怪的是,在Darwin或Linux Mint上,使用Electron 1.6.7,
require('electron').remote.getCurrentWebContents().getProcessId()
返回3,对于有效的进程ID看起来很小.
但是,从渲染器过程中,
process.pid
返回正确的渲染器进程ID,和
require('electron').remote.process.pid
返回正确的主进程ID.
这可以通过使用Darwin上的Activity Monitor应用程序或Linux Mint上的System Monitor应用程序来确认.