Uh oh!
There was an error while loading. Please reload this page.
Conversation
implemented getenv on node.js check memory leaks : printf ( "\n NODE.JS <%s> " ,getenv ( process.env.APPDATA ) ) ;
implemented : system command, works on node.js : usage : system ( "dir" ) ; system ( "node -v" ) ; system ( "dir c:\\windows" ); system ( "em++ node001-getenv.cpp -o main.js" );
added get env added pause added __SIGRTMIN added __SIGRTMAX
add signal , raise , pause , sigprocmask, __libc_current_sigrtmax __libc_current_sigrtmin
create example for getenv node.js
add example to use system command on node.js
show usage of signal raise
add usage for pause() command
usage sig proc mask
There was a problem hiding this comment.
our convention has the { on the same line
There was a problem hiding this comment.
ok i can repost you a code align ,with emscripten guide lines
{ in the same lines,
apply { in the same lines and tab code with 2 spacesghost
commented
Dec 3, 2015
i need you ask a question : about free() . I have seen that this function |
if environmet is node
kripken
commented
Dec 14, 2015
free is implemented in |
ghost
commented
Dec 15, 2015
you're right |
remove getnev implementation on emscripten.h. file to avoid confusion.
ghost
commented
Dec 16, 2015
yes, but if you try this code, free does not work : |
kripken
commented
Dec 21, 2015
I don't understand, what do you mean by "free does not free"? |
ghost
commented
Dec 21, 2015
the command ' free ' does not release the allocated memory 2015-12-21 20:22 GMT+01:00 Alon Zakai notifications@github.com:
|
ghost
commented
Dec 24, 2015
Happy Christmas Kripken ! 2015-12-21 20:55 GMT+01:00 claudio daffra daffra.claudio@gmail.com:
|
kripken
commented
Jan 7, 2016
Sorry for the delay here. I still don't follow. How do you know it isn't freeing the memory? |
ghost
commented
Jan 9, 2016
excuse me, for my bad english 2016-01-07 1:54 GMT+01:00 Alon Zakai notifications@github.com:
|
kripken
commented
Nov 2, 2018
This PR is quite old, closing. Feel free to reopen if still relevant. |
IngwiePhoenix
commented
Dec 12, 2020
Pretty sure I'll be poking a dead issue here. I am poking around with WebAssembly and I want to access variables from the real environment - well, not me specificaly, but SWIG would like to. I run it via Node. Studying the So far, so good. Passing environment variables though does not work unfortunately. Has a streamlined method of using environment variables been introduced in the meantime? Thanks! |
sbc100
commented
Dec 12, 2020
Emscripten seeds its environment from the If you would like to node-specific behaviour to mirror the real environment, and that is genuinely useful, and I think we would accept such a patch. But these change of changes that are node-specific can also hurt portability so we should consider them carefully. |
IngwiePhoenix
commented
Dec 12, 2020
Why not go for an option like |
sbc100
commented
Dec 12, 2020
Sure either of those approaches would work. That for loop in pre-js should work yes. |
IngwiePhoenix
commented
Dec 13, 2020
Had no luck so far. But I did find this: functiongetEnvStrings(){if(!getEnvStrings.strings){// Default values.// Browser language detection #8751varlang=((typeofnavigator==='object'&&navigator.languages&&navigator.languages[0])||'C').replace('-','_')+'.UTF-8';varenv={'USER': 'web_user','LOGNAME': 'web_user','PATH': '/','PWD': '/','HOME': '/home/web_user','LANG': lang,'_': getExecutableName()};// Apply the user-provided values, if any.for(varxinENV){env[x]=ENV[x];}varstrings=[];for(varxinenv){strings.push(x+'='+env[x]);}getEnvStrings.strings=strings;}returngetEnvStrings.strings;}The way if(ENVIRONMENT_IS_NODE){getEnvStrings.strings=process.env;}else{/* ...implement the "standard" env as seen above. */}then Looks like my best bet at this point is to look where this is generated and how I can change/update that and maybe make it a PR or something. But for now, I am a little lost as to how I can just add this feature without neccessarily modifying the Emscripten source. |
IngwiePhoenix
commented
Dec 13, 2020
Well, I did find a method. Hacky, but for now, works. LDFLAGS appended: Module.preRun=functioncustomPreRun(){ENV=Object.create(process.env);}This allows this program to display the proper #include<stdio.h>#include<stdlib.h>intmain() { puts(getenv("PATH")); }Not elegant but working. Wish there was an easier way to get this working, considering it's literally a one-liner. XD |
library.js , add system
i have updated in my branch library.js
to implement : system <stdlib.h>
it works on node.js
usage :
emscripten.h , add getenv
i have addedd getenv command <stlib.h>,,
it work on node.js
usage :
emscrpiten.h, added pause
raise SIGSTOP and SIGCONT;
usage :
pause(1000);
emscripten.h, added MACRO
__SIGRTMIN
__SIGRTMAX
to implement other two function :
__libc_current_sigrtmax
__libc_current_sigrtmin
library.signal.js
addedd :
signal , raise , pause ,
sigprocmask , __libc_current_sigrtmax ,
__libc_current_sigrtmin
example
add example, for this command , in tests :
node001-getenv.cpp
node002-system.cpp
signal001-signal-raise.cpp
signal002-pause.cpp
signal003-sigprocmask.cpp