]> Cypherpunks repositories - gostls13.git/commit
syscall: on wasm, do not panic if "process" global is not defined
authorRichard Musiol <mail@richard-musiol.de>
Mon, 7 Oct 2019 22:58:26 +0000 (00:58 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 8 Oct 2019 02:42:57 +0000 (02:42 +0000)
commitecba83520d4c34870e0f5f0997d59d4496957240
tree318b215f71f84b3e7a92016874a3e7bed8faa9e4
parent01ff213a51a6713958f80619f483eb2e731e034a
syscall: on wasm, do not panic if "process" global is not defined

When running wasm in the browser, the "process" global is not defined.
This causes functions like os.Getpid() to panic, which is unusual.
For example on Windows os.Getpid() returns -1 and does not panic.

This change adds a dummy polyfill for "process" which returns -1 or an
error. It also extends the polyfill for "fs".

Fixes #34627
Replaces CL 199357

Change-Id: Ifeb12fe7e152c517848933a9ab5f6f749896dcef
Reviewed-on: https://go-review.googlesource.com/c/go/+/199698
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/wasm/wasm_exec.js
src/syscall/syscall_js.go