在电子中,渲染器过程的pid被曝光
processId = require('remote').getCurrentWindow().getProcessId()但是,这在最近的版本(1.4.x、1.5.x、1.6.x)中不再有效。
还有其他方法来获取呈现程序进程的pid,即Windows的pid吗?
发布于 2017-05-18 18:03:22
发布于 2017-05-16 23:02:34
奇怪的是,在达尔文或Linux铸币厂,电子1.6.7,
require('electron').remote.getCurrentWebContents().getProcessId()返回3,对于有效的进程id来说,这似乎很小。
然而,从渲染程序来看,
process.pid返回正确的呈现程序进程id,以及
require('electron').remote.process.pid返回正确的主进程id。
这可以通过使用达尔文上的Activity应用程序或Linux上的System应用程序来证实。
发布于 2017-05-16 09:32:30
以下略为修改的版本适用于我
require('electron').remote.getCurrentWebContents().getProcessId()示例:
const { app, BrowserWindow } = require('electron')
app.once('ready', () => {
var br = new BrowserWindow()
br.once('focus', () => {
br.webContents.openDevTools({detach:true})
br.webContents.executeJavaScript(`
const remote = require('electron').remote
console.log(remote.getCurrentWebContents().getProcessId())
`)
})
br.loadURL('http://google.com')
})在1.4.13测试
https://stackoverflow.com/questions/43989590
复制相似问题