subprocess to C program

bobicanprogram icanbob at gmail.com
Sun Dec 14 07:32:46 EST 2008


On Dec 13, 10:09 pm, MRAB <goo... at mrabarnett.plus.com> wrote:
> Aaron Brady wrote:
> > On Dec 13, 7:51 pm, Grant Edwards <gra... at visi.com> wrote:
> >> On 2008-12-14, MRAB <goo... at mrabarnett.plus.com> wrote:
>
> >>>> I am writing a C process and I want to read data from a file that I
> >>>> write to in Python.  I'm creating a pipe in Python, passing it to the
> >>>> C process, and calling '_read'.  It gives me error 9, bad file number.
> > snip
> >>>> meaning that 'ct' is -1, 'readfd' is 3, and 'errno' is 9.  I want 'ct'
> >>>> to be 11 at this point.  Thanks in advance.
> >>> It looks like the ids aren't system global.
> >> They certainly aren't in Unix: Their a property of the process.
>
> >> --
> >> Grant
>
> > I'm not on Unix.  It has to be possible somehow.  Do I need to set
> > permissions on the IDs?  Are Stdin and Stdout my only options?  Or
> > does Popen prevent sharing IDs somehow?
>
> You'd be better off using sockets.


You might also consider using SIMPL (http://www.icanprogram.com/simpl)
SIMPL has had a Python interface for about 5 years now.   There is an
online tutorial here. (http://www.icanprogram.com/06py/main.html)

In one of your responses you mentioned that you were not on Unix (and
I presume Linux).   SIMPL-Python has recently been extended to work
transparently from a Windows OS as well.

bob
SIMPL project coordinator



More information about the Python-list mailing list