I am having some issues getting spawn() from the system/child_process SDK module to execute a command successfully on Centos 6.6. I am calling it as
let result = child_process.spawn(command, args, options)
Watching in the debugger, I see that after this step that result contains properties killed: false, exitCode: 0, and a plausible value for the pid. However, I can’t see any evidence that the command was actually executed. I tried running a command that would touch a file and no file was created. I tried running /bin/uname and catching stdout as illustrated in the example here: https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/system_child_process but my callback was not called. I tried making the command /bin/sleep and the argument 60, but when I checked with ps the pid shown in result was not associated with any active process. If I change command to something invalid, result changes to having an exitCode of -1 and the console shows a “File not found” error, so spawn is doing something.
I tried using child_process.spawn on Arch Linux and it worked for me there. What could be different? What could I do to debug this? I’m not seeing any error message.
Have you tried running exec() instead? Also it might be good to run Firefox from the command line to see its output. There might be clues there about this problem.
I’m trying to run gnome terminal or any application with GUI (firefox , gedit , etc …). In Windows 7 I have been able to run cmd from the Firefox extension, but in linux not work … I think it’s a problem with the configuration of X11. Any help?
in node.js, spawn() and exec() inherit the
environment variables from the parent process, by default. The SDK
versions don’t: so when you specify a command you must pass in a
complete path to the command or use the env option to set up the child process environment.
You can get the $DISPLAY environement variable with the add-on SDK using the env proxy of the sdk/system module. However you have to fetch each value explicitly, the values cannot be enumerated.