2

I am trying to run dvipng process from a thunderbird extension using Components.interfaces.nsIProcess. I need to read standard output of the process, but I am not able to find a way to do that. I found some threads on nsIProcess2, but that one was (as it seems) never fully implemented with stdout. Any suggestions?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
eudoxos
  • 18,545
  • 10
  • 61
  • 110

1 Answers1

2

nsIProcess2 is unrelated - it was implemented but later folded into nsIProcess. It was only about starting processes asynchronously.

The relevant bugs are bug 484246 and bug 68702. The latter has been resolved but so far that code doesn't ship with Firefox/Thunderbird by default (it's quite a bit of code that neither Firefox nor Thunderbird need themselves). So your options are:

  • Build IPCModule yourself and make it part of your extension - not recommendable because it will cause lots of troubles.
  • Create a native library that will call dvipng for you, use it via js-ctypes - should be the easiest solution.
  • Turn dvipng into a library and use it directly via js-ctypes - probably not too hard either, this will also give you better performance.
Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
  • I would like to build a thunderbird extension that will cross-platform if possible, without building additional libraries. Am I getting it right that in javascript itself (I am new to this language, sorry), there is no way to call a process while reading its standard output, or at least redirecting its standard output to file? – eudoxos Sep 07 '11 at 08:25
  • 1
    Yes, that's true unfortunately. You might get the "redirecting output to a file" part by calling the command line shell with the right parameters. – Wladimir Palant Sep 07 '11 at 09:21
  • given what you say, how realistic is it to write an extension in python (my language of choice otherwise)? I know there is [PythonExt](http://code.google.com/p/pythonext), but I could not google up a single real extension coded in python. – eudoxos Sep 07 '11 at 13:32
  • 1
    I would recommend forgetting it. PyXPCOM is mostly abandoned and shipping it with your extension is lots of trouble. – Wladimir Palant Sep 07 '11 at 13:57
  • I figured the easiest would be to have javascript spit out shell script (with all output redirection and so on, and writing needed stuff to output files) and run it using `nsIProcess`. Linux-only, but... good enough for now. – eudoxos Sep 07 '11 at 14:11