NsIProcess

From MozillaWiki
Jump to: navigation, search

nsIProcess2 API Proposal

Project page: Fixing nsIProcess

JS API

Components.utils.import("resource://gre/Process.jsm");

function callback(evt) {
   // do stuff
}

var p = new Process(["appdir/myapp", "someargs], 
                    {cwd: "ProfD", charset: "utf8"},
                    callback);
p.start();

// or without callback

var p = new Process(["appdir/myapp", "someargs], 
                    {cwd: "ProfD", charset: "utf8"});
p.start();

var ret = p.communicate("something");

Underlying XPCOM interfaces

interface nsIProcess2 : public nsISupports
{
 void init(in nsIFile program);

 void inheritStdin();
 void pipeStdin(in nsIPOSIXOutputStream);

 void inheritStdout();
 void fileStdout(in nsIFile);
 void pipeStdout(in nsIPOSIXInputStream);

 void inheritStderr();
 void fileStderr(in nsIFile);
 void pipeStderr(in nsIPOSIXInputStream);

 readonly attribute unsigned long result;
 readonly attribute unsigned long pid;
 attribute nsIObserver listener;

 void run([array, size_is(argv)] in wstring argv, in unsigned long argc);
};

interface nsIPOSIXOutputStream : public nsIOutputStream
{
 /* the native POSIX file descriptor for this stream */
 readonly attribute unsigned long fd;
};

interface nsIPOSIXInputStream : public nsIInputStream
{
 /* the native POSIX file descriptor for this stream */
 readonly attribute unsigned long fd;
};

interface nsIPipeManager : public nsISupports
{
 nsIPOSIXInputStream createIncomingPipe();
 nsIPOSIXOutputStream createOutgoingPipe();

 nsIPOSIXInputStream readFile(in nsILocalFile file);
 nsIPOSIXOutputStream writeFile(in nsILocalFile file);
};