bit / subprocess

subprocess.jsm - start a process in your Firefox Extension and read/write data to/from it using stdin/stdout/stderr streams.
26 stars 9 forks source link

stdinWorker: expected type int, got (void 0) #1

Closed dfranganillo closed 11 years ago

dfranganillo commented 12 years ago

Hi, I'm trying to develop a small extension and up until now I've been unable to launch a simple process via subprocess.jsm with standard input. This is the code snippet I cannot get to work :(

    var outval = {};
    outval.ret = 0;
    outval.stdout = '';
    outval.stderr = '';
    var gpg_exec = 
        subprocess.call
        (
        {
            command: "/bin/echo",
            arguments: ['-ne'],
            done: function(result) 
            {
            outval.ret = result.exitCode;
            outval.stdout = result.stdout;
            outval.stderr = result.stderr;
            },
            stdin: "Hola\n"
        }
        );
    gpg_exec.wait();
    dump ("<<ERROR>>\n" + outval.stderr);
    dump ("<<SALIDA>>\n" + outval.stdout);

And the output it produces (with debug enabled) is:

subprocess started; got PID 23570
getlimit: maxFD=1024
Creating new stdin worker
sending 5 bytes to stdinWorker
trying to close stdin
sending close stdin to worker
Got msg from stdout: initialising library with libc.so.6
Got msg from stdout: waitpid signaled subprocess stop, exitcode=0
Got msg from stdout: poll returned HUP
Pipe stdout closed
Got msg from stderr: initialising library with libc.so.6
Got msg from stderr: poll returned HUP
Pipe stderr closed
Cleanup called
trying to close stdin
stdinWorker: initialising library with libc.so.6
stdinWorker: trying to write to 50
trying to close stdin
got error from stdinWorker: expected type int, got (void 0)
stdinWorker: closing stdin

Stdin pipe closed
<<ERROR>>
<<SALIDA>>

I've tried to use the stdin function form with the same results. Thanks.

bit commented 12 years ago

have you tried just echo? afaik echo is not a good test since it does strange things with stdin/out/err subprocess.jsm closes stdin after writing to it.