Skip to content

Instantly share code, notes, and snippets.

@jklaiho
Created July 13, 2010 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jklaiho/473786 to your computer and use it in GitHub Desktop.
Save jklaiho/473786 to your computer and use it in GitHub Desktop.
// in REPL
var exec = require('child_process').exec;
var child;
var uid = 123;
child = exec('id -u root', function(error, stdout, stderr) {
// trying to update the uid variable outside this function
uid = parseInt(stdout, 10);
console.log(uid) // prints 0
});
// ...
// afterwards, when the child process is good and done:
console.log(uid) // still prints 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment