Search code examples
javascriptnode.jselectronchromium

Acquire renderer process id in Electron


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 ?


Solution

  • The method getOSProcessId() to acquire the renderer's OS pid (not the routing id) was added to Electron v1.7.1. Here is the original pull request.

    require('electron').remote.getCurrentWebContents().getOSProcessId();