Difference between revisions of "User:Jamesboston/nsIProcess"

From CDOT Wiki
Jump to: navigation, search
(News and Progress)
(Relevant bugs)
Line 65: Line 65:
==Relevant bugs==
==Relevant bugs==
Implement a replacement for nsIProcess
nsIProcess.kill() does not work on Win32<br />
nsIProcess.kill() does not work on Win32<br />

Revision as of 14:57, 19 March 2009

Name of Project

Fix nsIProcess


The nsIProcess API will be given a new spec that includes inter-process communication and then implemented.


James Boston


None (yet).

News and updates


A blog about the ongoing project to fix nsIProcess:

News and Progress

Sept 21, 2008: A first draft (an alpha version really) of the API is posted.

Sept 22, 2008: Released an updated version of an extension that serves as a temporary work around for nsIProcess bugs.

Sept 25, 2008: Submitted patch to bugzilla.

Oct 3, 2008: Submitted revised patch to bugzilla.

Oct 12, 2008: Opened a bug on NSPR lack of unicode support for Unicode arguments.

Nov 11, 2008: Submitted a new patch to bugzilla with Unicode support for Windows.

Nov 23, 2008: Submitted a new patch to bugzilla with isRunning() method.

Jan 25, 2009: Submitted a new patch with unit tests.

Mar 5, 2009: Submitted a new patch with minor revisions. The bug has now also been marked blocking‑fennec.

Mar 9, 2009: Changed interface to return void on run.

Mar 12, 2009: Patch pushed to mozilla-central. (Followed by a minor bustage fix.)

Mar 19, 2009: Filed a new enhancement bug that ties together the various features in the next stage of development.


The API for nsIProcess is not fully implemented. At present, the PID of a created process is not retained and cannot be killed. The API would also benifit from a new spec that includes inter-process communication.

An example of an API that for creating processes and communicating with them through STDIN/STDOUT is the Python subprocess module: http://docs.python.org/lib/node528.html

The goal of this project is to create a similar API for Mozilla.

API proposal


Existing API

Code snippet of how to use the existing API

Existing Code


Relevant bugs

Implement a replacement for nsIProcess https://bugzilla.mozilla.org/show_bug.cgi?id=484246

nsIProcess.kill() does not work on Win32

Implement inter-process communication (IPC) in Mozilla

PR_CreateProcess in NSPR needs unicode support

Proposed patches

patch092408.txt: This patch fixes the kill() method by putting an attribute into the class that is a Win32 defined struct for holding a reference to a process, and then using that reference to terminate the process. This approach is not considered optimal because it adds more code complexity.

patch092508.txt: This patch removes Window's specific code from the implementation. Instead, Windows and all other platforms use the Netscape Portable Runtime (NSPR) to create processes. Additionally, the logic for blocking is modified. For non-blocking processes, the code previously invoked logic in the NSPR that detached a process and deleted the reference to it, rendering the kill() function useless. This has been changed so that the kill() function works unmodified. However, it looks as the the NSPR does not support OS X process creation/termination. (In fact, the remaining Mac specific code in nsProcessCommon.cpp may not actually do anything.) Additional implementation may be necessary in the NSPR.

patch100308.txt: Removed the Mac code. The NSPR seems to do everything necessary. The destructor has also been coded to detach a process if it hasn't been killed yet.

patch102208.txt: Implemented returning the PID for Windows. Added some code to clean up memory after kill is used, but haven't verified that it works.

patch102808.txt: Implemented returning the PID for Mac and Linux. Solution assumes too much about structure of PRProcess.

patch111108.txt: No longer trying to use NSPR for process management. Unicode support added. Run/Kill is Windows only.

patch112308.txt: A more conservative patch that leaves much of the Windows specific code in tact, but solves the problem of kill() working and returning a PID. Also, adds an isRunning() method.

patch112508.txt: Updates the previous patch to fix a problem with returning PIDs on Mac.

patch112808.txt: Add unit tests for all platforms, but the test fails on Mac.

358763: Unit test passes on all platforms.

365651: Minor ammendments suggested by reviewer.

366315: Change run to a void return.

336354: Bustage fix.

Meetings (Chronological)

Sept 19, 2008: Discussion with Benjamin Smedberg and David Humphrey to discuss the new API proposal.

Sept 22, 2008: Discussion with Mark Finkle and David Humphrey about the API design.

Sept 23, 2008: Discussion with Mark Finkle about using NSPR.

Oct 8, 2008: Discussion about string types and Windows paths in NSPR.

Oct 29, 2008: Advice regarding PRProcess type.

Nov 5, 2008: Getting advice on callbacks across XPConnect divide.

Nov 7, 2008: Round table on Unicode support.

Nov 23, 2008: Discussion about pathnames in xpcshell.