-
Notifications
You must be signed in to change notification settings - Fork 3.4k
add functions <signal.h> , getenv/system (node.js)<stdlib> #3948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
// Can't call external programs. | ||
___setErrNo(ERRNO_CODES.EAGAIN); | ||
return -1; | ||
system: function(command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our convention has the {
on the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 spaces
i need you ask a question : about free() . I have seen that this function |
if environmet is node
free is implemented in |
you're right |
remove getnev implementation on emscripten.h. file to avoid confusion.
yes, but if you try this code, free does not work :
|
I don't understand, what do you mean by "free does not free"? |
the command ' free ' does not release the allocated memory 2015-12-21 20:22 GMT+01:00 Alon Zakai [email protected]:
|
Happy Christmas Kripken ! 2015-12-21 20:55 GMT+01:00 claudio daffra [email protected]:
|
Sorry for the delay here. I still don't follow. How do you know it isn't freeing the memory? |
excuse me, for my bad english 2016-01-07 1:54 GMT+01:00 Alon Zakai [email protected]:
|
This PR is quite old, closing. Feel free to reopen if still relevant. |
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! |
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. |
Why not go for an option like |
Sure either of those approaches would work. That for loop in pre-js should work yes. |
Had no luck so far. But I did find this: function getEnvStrings() {
if (!getEnvStrings.strings) {
// Default values.
// Browser language detection #8751
var lang = ((typeof navigator === 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
var env = {
'USER': 'web_user',
'LOGNAME': 'web_user',
'PATH': '/',
'PWD': '/',
'HOME': '/home/web_user',
'LANG': lang,
'_': getExecutableName()
};
// Apply the user-provided values, if any.
for (var x in ENV) {
env[x] = ENV[x];
}
var strings = [];
for (var x in env) {
strings.push(x + '=' + env[x]);
}
getEnvStrings.strings = strings;
}
return getEnvStrings.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. |
Well, I did find a method. Hacky, but for now, works. LDFLAGS appended: Module.preRun = function customPreRun() {
ENV = Object.create(process.env);
} This allows this program to display the proper #include <stdio.h>
#include <stdlib.h>
int main() { 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