Acquire renderer process id in Electron

Viewed 5145

In Electron, the renderer process's pid was exposed by

processId = require('remote').getCurrentWindow().getProcessId()

which, however, is no longer valid in recent releases (1.4.x, 1.5.x, 1.6.x).

Is there any other way to get the pid of the renderer process, i.e. the pid for the Windows ?

4 Answers

As of electron 14 the remote module has been removed

// Deprecated in Electron 12:
const { BrowserWindow } = require('electron').remote


// Replace with:
const { BrowserWindow } = require('@electron/remote')

// In the main process:
require('@electron/remote/main').initialize()
Related