On Tue, May 28, 2013 at 12:47 PM, Shane Carr <[email protected]> wrote: > I am writing an application that spawns a child process and interacts with > it via STDIN/STDOUT/STDERR through the life of the program. > > When I run my script (the one that Node.JS spawns) from the terminal, it > waits for user input, as expected. In addition, if I write a short C script > that spawns the process via execvp (the same way that Node seems to do it > under the hood), the program waits for user input. However, when I use > Node's API, the process is killed soon after it is created, perhaps when it > starts waiting for input. Consider the code: > > var spawn = require("child_process").spawn; > var shell = spawn("./run_shell.sh"); > > // Write the child's STDOUT to the main STDOUT > shell.stdout.on("data", function(data){ > console.log(data.toString("utf8")); > }); > > // Listen for the exit event > shell.on("exit", function(code){ > console.log("Exited with code "+code); > }); > > // Detect signals on the child process (for debugging) > var allSignals = ["SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGABRT", > "SIGFPE", "SIGKILL", "SIGSEGV", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", > "SIGUSR2", "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU", > "SIGBUS", "SIGPOLL", "SIGPROF", "SIGSYS", "SIGTRAP", "SIGURG", "SIGVTALRM", > "SIGXCPU", "SIGXFSZ", "SIGIOT", "SIGEMT", "SIGSTKFLT", "SIGIO", "SIGCLD", > "SIGPWR", "SIGINFO", "SIGLOST", "SIGWINCH", "SIGUNUSED"]; > for(var i=allSignals.length-1; i>=0; i--){ > var signal = allSignals[i]; > shell.on(signal, (function(signal){ > return function(){ console.log(signal+" received by child"); }; > })(signal)); > } > > When I run the above application, all I get is the lines of my run_shell.sh > before that script starts waiting for STDIN, and then a "Exited with code > 0". No signals are detected. > > This behavior is not exhibited with all programs that wait for input on > STDIN. > > It it is important, my shell script involves the use of an SELinux sandbox, > and the issue is exhibited only when SELinux is in enforcing mode. (When > run outside of Node, the script works as expected regardless of whether > SELinux is running.) > > When I run the application in debug mode, when the following line (in > child_process.js) is run, I can tell by monitoring the shell's process that > the script starts and exits, even when the debugger keeps Node paused: > > *915 var r = this._handle.spawn(options); > > The debugger won't let me step inside that method. I assume this is because > that particular method is an entrypoint into the C++ backend of Node. > > What might be causing Node to kill the process? How could I go about > debugging to find out what part of Node is the culprit? Thanks!
It sounds like an SELinux policy is blocking something. `strace -f` and /var/log/messages might give more insight. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
