subprocess to C program
MRAB
google at mrabarnett.plus.com
Sat Dec 13 20:29:59 EST 2008
More information about the Python-list mailing list
Sat Dec 13 20:29:59 EST 2008
- Previous message (by thread): subprocess to C program
- Next message (by thread): subprocess to C program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Aaron Brady wrote: > Hi, > > 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. > > Python code: > > import subprocess as s, os > r, w= os.pipe( ) > os.write( w, 'abcdefghij\n' ) > a= s.Popen( [ r'C:\Documents and Settings\usr\Desktop\working > \try_start', '%i'%r, '%i'%w ] ) > > C code: > > char buf[ 16 ]; > memset( buf, 0, 16 ); > int readfd= atoi( argv[ 1 ] ); > int ct= _read( readfd, buf, 15 ); > printf( "\n\n'_read %i %i %i': %s\n", ct, readfd, errno, buf ); > > Output: > > '_read -1 3 9' > > 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.
- Previous message (by thread): subprocess to C program
- Next message (by thread): subprocess to C program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list